Most Useful Linux Commands You Need Everyday
What are the basic and most useful Linux commands you need every day to speed-up your execution?
In this tutorial, I am listing some of the important Linux commands that you will find very useful in your daily work routine.
One of the best things about Linux is that you will find many useful commands. Keeping those commands handy, you feel doing a lot of things in just a few seconds.
If you get habitat using these useful Linux commands, gradually, your productivity will start increasing.
Without any ado, let’s see.
Note: I will keep this list updated with more of such useful commands as I come across.
1. Sort the Files and Directory by Time
How to sort the files and directory by Time?
The basic command to list all the files and directory inside the current directory path.
You can see that the directories listed are not sorted.
If you want to sort the files by their modification time, you need to run the following command.
$ ls -lrt
- “l” is for the long listing format. It shows detail about each directory like read/write permission, user, time and date of modification…
- “r” is to reverse the order of the directory listing. If you don’t use this parameter, it shows the directories in descending order of modification.
- “t” is to sort the directories by modification time.
2. Change Current Directory Temporarily to Execute the Command
How to change Current directory temporarily to execute the command?
Do you want to execute the command in a temporary directory in your bash?
Here is a simple command you can use to change the current directory temporarily and then execute your command.
We all the command to change the directory.
After this command, your current directory will be changed permanently. You can check the current directory using
Now, instead of changing directory permanently you can club
cd command with the command you want to execute.
(cd <your_directory_path> && <your_command_to_execute>)
Don’t forget to enclose the commands inside the opening and closing the bracket (parenthesis).
Rather than changing your directory, it executes the command in the directory you have mentioned.
Let check the current directory first.
Change the current directory temporarily and execute the command.
$ (cd /tmp && ls)
It will list out all the files in the /tmp directory.
You can see that the current directory is not changed.
Where you can use this command?
This command is very useful if you writing any script and you want to execute certain commands in a specific directory. You don’t need to change the current directory path.
3. Change the Permission for all the Files in Directory and Subdirectories
How to change the permission for all the files in directory and subdirectories?
Sometimes, while running the application you get permission denied issue. There can be multiple scripts in your project directory for which you don’t have permission to execute. Going to each script and giving permission is not convenient. Rather, you can set the permission for all the files in the project directory using a single command.
You can use a simple
chmod command with the
Go to the desired directory and run the following command.
chmod -R 777 *
777will give read, write and execute permissions for all the files in the current directory and subdirectories. (You should give the permission based on your requirement.)
*is used to apply the changes to all the files.
4. Check Available, Cache and Free Memory
You can use the free command to check the total, available, cache and free memory in Ubuntu (Linux).
The option ‘-h’ is used to print all the memory metrics in a human-readable format.
There are multiple options you can use with the free command.
Some More Useful Linux Commands You Should Learn
- 7 Hostname Linux Commands to know more about your Linux host
- Commands to find the size of each directory
- Commands to mount/unmount devices
What are the useful Linux commands you use every day? Please mention in the comment, we will add it to this list.
Keep Wrestling and Start Learning Linux!