Whether we are a Linux beginner or a seasoned user, mastering a set of fundamental commands is crucial for efficient system management and troubleshooting. Here’s a roundup of common Linux commands that will be invaluable in our day-to-day tasks:
CD (change Directory)
This command is used to navigate between directories.
Examples:
cd /home/user: Moves you to the /home/user directory.
cd ..: Moves up one directory level.
cd ~: Quickly navigate to the home directory.
cd -: To navigate to the previous directory (or back)
LS (List Directory Contents)
The ls command is one of the most basic yet important commands in Linux. It displays the contents of a directory. It is commonly used to navigate and inspect files and directories.
ls: Lists files and directories in the current location.
ls -l: Displays detailed information such as file permissions, ownership, and modification dates.
ls -ld: Displays detailed information such as file permissions about top level directory.
ls -a: Shows hidden files and directories (those starting with .).
PWD ā Print Working Directory
Shows the absolute path of the current working directory.
dwk@dwk-virtual-machine:~$ pwd
/home/dwk
CPā Copy Files and Directories
The cp command is essential for duplicating files or directories.
-r is used for recursive
dwk@dwk-virtual-machine:~$ cp -rv file1 file2
'file1' -> 'file2'
mv ā Move or Rename Files
Moves files or directories to a different location or renames them without changing their contents.
mkdir ā Make Directory
Creates one or more new directories. The -p option allows you to create nested directories without errors if parent directories don't exist.
dwk@virtualmachine:~$ mkdir -p dir1/dir2/dir3
dwk@virtualmachine:~$ tree dir1/
dir1/
āāā dir2
āāā dir3
Touch ā Create Empty Files
Creates an empty file if it doesn't exist or updates the access and modification timestamps of an existing file.
dwk@virtualmachine:~$ touch file_created_by_touch
dwk@virtualmachine:~$ ls
dir1 file_created_by_touch
