Skip to Content

10 useful commands you need to know in Linux

Here are 10 useful commands that you should know in Linux:

ls: List files and directories in the current directory.
Example: ls -l (lists files and directories in long format)

cd: Change directory.
Example: cd /path/to/directory (changes the current directory to the specified path)

pwd: Print the current working directory.
Example: pwd (displays the current directory path)

mkdir: Create a new directory.
Example: mkdir new_directory (creates a directory named “new_directory”)

rm: Remove files and directories.
Example: rm file.txt (deletes the file named “file.txt”)
Example: rm -r directory (deletes the directory and its contents recursively)

cp: Copy files and directories.
Example: cp file.txt new_file.txt (copies “file.txt” to “new_file.txt”)

mv: Move or rename files and directories.
Example: mv file.txt new_directory/ (moves “file.txt” to the “new_directory” directory)
Example: mv file.txt renamed_file.txt (renames “file.txt” to “renamed_file.txt”)

cat: Display the contents of a file.
Example: cat file.txt (displays the contents of “file.txt” in the terminal)

grep: Search for patterns in files.
Example: grep “pattern” file.txt (searches for “pattern” in the “file.txt” and displays matching lines)

sudo: Execute a command with administrative privileges.
Example: sudo apt-get update (updates the package lists using administrative privileges)