Useful Commands for Linux Beginners- Part 1

Useful Commands for Linux Beginners- Part 1

Linux has a broad range of commands available but I will try to list the most commonly used commands that will make life easier while working with Linux as a beginner at your workplace.

  • cat

cat ('concatenated') is used to view the file contents to the terminal window.

Usage:

cat {filename}
  • cd

cd ('change directory') is useful while changing the directory you want to work on.

Usage:

cd folderpath1/

Also, if you want to go back to the root directory simply use cd

  • find

find command is used to find the file by name you know exists but can't remember where exactly it is!

Usage:

find . -name *{filename}*

Also, If you want the search to be case insensitive use the -iname (insensitive name) option.

find . -iname *{filename}*
  • finger

The finger command provides you short information about a user, including the time of the user’s last login, the user’s home directory, and the user account’s name.

Usage:

finger {username}
  • grep

The grep command searches for lines that contain a search pattern. It can also search the contents of files. Here we’re searching for the word “error” in all text files in the current directory.

Usage:

grep {text_to_search}  {filename}

grep is most commonly used with the pipe when we want to search in output that resulted from the first command

Usage:

curl -I https://www.google.com | grep "Date"
  • head

The head command gives you a listing of the first 10 lines of a file. If you want to see fewer or more lines, use the -n (number) option

Usage:

head -n 5 filename.txt    #will list the first 5 lines
  • tail

Similarly, the tail command gives you the last 10 lines of a file with the option to specify the number of lines you want to see by using the -n option again

Usage:

tail -n 5 filename.txt    #will list the first 5 lines
  • less

less command is used to view files without the need to open an editor to check quickly. You scroll forward and backward through the file using the Up and Down Arrow keys, Press the Q key to quit from less.

Usage:

less {filename}
  • ls

ls command is very handy when you want to find the lists of files and folders present in the current working directory. It also helps you to see hidden files when used with an option. -a

Usage:

ls -a  # lists files including hidden ones
ls -l # lists files with read & write permission on that file or folder
  • sudo

The sudo command is required when any action requires root or superuser permissions, such as installing software, delete files, or edit files when you are not permitted to do so.

Usage:

sudo vi {filename}
  • mkdir

mkdir is used to create a new directory under the present working directory

Usage:

mkdir {foldername}
  • mv

mv is used to move files or folders from one place to another. To move a file you must specify mv where the file is and where you want it to be moved.

Note: If you move a file within the same folder then it will be as good as renaming the file.

Usage:

mv {source_file_or_folder_name} {destination_file_or_folder_name}
mv  source.txt. /Destination/dest.txt.  # will move source file to Desktop folder

Thank you for taking the time to read! I hope this will help you on your journey with Linux.

Note: Photo by Sora Shimazaki from Pexels