15 Linux Commands You Will Need In Your Daily Life

Linux users can’t just live with the GUI, CLI usage makes the work more efficient and fast. Hence I have brought together a set of 15 commands which are very useful for your daily works in Linux.

Linux Commands:

1.pwd

This command displays the current path where the terminal is situated. 

Syntax:

CommandExplanation
pwdGives the path of the current working directory
pwd
pwd

2.ls 

This command displays all the files in the current directory.

Syntax:

CommandExplanation
ls pathLists all the files in the path given; if no path is given, then lists all files in the current directory
ls -lLists all the files with all the permissions attached and timestamps (long format)
ls -aLists all the files + the hidden files (dotfiles)
ls *.jpgLists all the jpg files in the current directory
ls
ls

ls can be used for a lot more things. To know more about it, you can use the command: man ls 

3.echo

The echo command is widely used in bash and shell scripts to output text to a screen or a file.

Syntax:      

CommandExplanation
echo Any text you want Prints any text you want
echo “Any text you want”Prints any text you want using quotations

Echo can be used with or without the quotes though usage of double quotes will be useful when working with large text or escaping some special characters in Linux.

echo
echo
Redirecting text to a file
Redirecting text to a file

4.cat 

Cat command is frequently used in Linux; it reads the input from the file and gives the output to the screen. Cat command can also be used to create and concatenate files.

Syntax:

CommandExplanation
cat filenameReads the given file
cat > filenameCreates new files
cat filename
cat filename

cat can be used to create files using the redirection operator (>). Just type cat > filename you want and enter the text you want to input into the file, and press Ctrl+D to end the terminal input. 

Creating a file using cat
Creating a file using cat

5.touch

The touch command is another command used to create files in Linux.

Syntax:

CommandExplanation
touch filenameCreates a single file
touch filename1 filename2 filename3Creates multiple files
touch filename
touch filename
touch filename1 filename2
touch filename1 filename2

6.rm 

Rm command is used to delete any file or directory. 

Syntax:

CommandExplanation
rm filenameDeletes the given file 
rm *.txtDeletes all files with .txt extension 
rm -i filenameWill ask before deleting the file
rm -r directoryWill delete recursively , used to delete directories 
rm filename
rm filename
rm -i filename
rm -i filename

7.cd 

Cd command is used to change the current working directory in Linux.

Syntax:

CommandExplanation
cdmove to users home directory from anywhere
cd .. move one step back 
cd pathchange to the path given 
cd ..
cd ..
cd path
cd path

8.mv 

  • ►Mv command is used to move one or more files or directories from one location to another location.
  • ►It can also be used to rename a file or a directory.

Syntax:

CommandExplanation
mv source destination Moves a file from sorce location to destination
Moving file testing to downloads
Moving file testing to downloads

In the above example, I have moved the file testing in Desktop to Downloads and used ls and grep to check if it’s moved.

9.grep

Grep command is an excellent CLI utility used to search for text in a file or can also be used to locate files in a directory. Learning to use grep and regular expressions will simplify lots of work for sysadmins.

Syntax:

CommandExplanation
grep “word” filenameSearches for a word given in the given filename
grep -c “word” filenameGives the count of matches of the word in the given file
grep -i “word” filenameSearches for a word shown in the given file ignoring the case sensitivity
grep -i “word” filename
grep -i “word” filename
grep “word” filename
grep “word” filename

In the above example, I have moved the directory testing in Desktop to Downloads and used ls and grep to check if it’s moved.

10. find

  • ►Find command is an excellent CLI utility used to search and locate files based on a set of conditions you specify.
  • ►Find can be used in various situations like file size, permissions, date, etc. 

Syntax:  

CommandExplanation
find . -name filename.txt Searches for the given filename in the current directory
find ~/Desktop -name filename.txtSearches for the given filename in Desktop
find ~/Downloads -type f -name “*.php”Searches for all php files in Downloads dir
find ~/Desktop -type f -emptyFind all empty files in Desktop 
 find ~/Desktop -type d -emptyFind all empty directories in Desktop
find ~/Downloads -type f -name “*.txt”
find ~/Downloads -type f -name “*.txt”

11.sudo 

  • ►Sudo command is widely used to obtain administrator or root privileges.
  • ►For example, if you want to edit any system files which need root permissions, you can use the sudo command.

Syntax:

CommandExplanation
sudo cat anyfileAttaching sudo to any command will give root privileges
sudo -s Runs the shell specified by SHELL Environment variable 
sudo -lPrints the allowed privileges for the current user
sudo cat anyfile
sudo cat anyfile

12.ping

Ping command is used to check the connection to a website, verifying if a website is up or down.

Syntax:   

CommandExplanation
ping ipaddress Ping any ipaddress
ping www.example.comPing any website

Receiving ICMP Packets = Up , Unreachable = Down

13.zip

  • ►zip command is a compression and file packaging utility for Linux. Zip is used to reduce the file size.
  • ►You can add lots of files into a single zip and send it over the internet.

Syntax:

CommandExplanation
zip filename_of_zip files_to_be_added_to_zipZips a file
zip images.zip *.png
zip images.zip *.png

14.chmod 

chmod command is used to grant permissions to a file or a directory. This command is exceptionally crucial for sysadmins. Giving permissions for different users and allowing them to access files according to policies is essential for every company to ensure security.

There are 3 different permissions i.e Read(r) , Write(w) and Execute(x).

Syntax:

CommandExplanation
chmod +x numbers.pyAdds executable permission to a python file
chmod +r numbers.pyAdds readable permissions to a python file
chmod +w numbers.pyAdds writable permissions to a python file
chmod +x numbers.py
chmod +x numbers.py
  • chmod command can be combined with the find command to change permissions for directories and a lot more.
  • To know more, use the command: man chmod .

15. ps 

The ps command is used to list currently running processes along with their PIDs. 

Syntax:

CommandExplanation
ps alists all processes of all the users 
ps aulists all the processes in a user-oriented format 
ps auxlists all the processes in user-oriented format and shows processes that are not started from the terminal.

The most common usage of ps command is: ps ax | grep “The process you want.” 

ps -ax
ps -ax

PID: Unique Process ID for each process

TTY: Name of controlling terminal for the process

CMD: The command which was used to start the process 

TIME: CPU time of process shown in Minutes and seconds.

Conclusion : 

We have looked into 15 Important Commands needed for daily life in detail. I hope new Linux users who are intimidated by commands can now switch to CLI after reading this post. If you have any questions or feedback, feel free to leave a comment.

I also run a small youtube channel on some exciting topics, do look into it.

https://www.youtube.com/channel/UCBO2LHhj4-SYejcaE3YfuNg

Leave a Reply

%d bloggers like this: