Learn Linux terminal (Linux shell), From Zero to Hero: The Complete Beginner Linux Guide for command line mastery WITHOUT EXAMPLES
The Linux terminal, also known as the command line or shell, is a text-based interface that allows users to interact with the operating system using commands. It provides a powerful and efficient way to perform various tasks and manage the system.
3 min readJun 10, 2023
FOR EXAMPLES FOR EACH COMMAND CHECK THE STORY:
FILE COMMANDS
$ ls #===> Directory listing
$ ls -al #===> Formatted listing with hidden files
$ ls -lt #===> Sorting the Formatted listing by time modification
$ cd dir #===> Change directory to dir
$ cd #===> Change to home directory
$ pwd #===> Show current working directory
$ mkdir dir #===> Creating a directory dir
$ cat >file #===> Places the standard input into the file
$ more file #===> Output the contents of the file
$ head file #===> Output the first 10 lines of the file
$ tail file #===> Output the last 10 lines of the file
$ tail -f file #===> Output the contents of file as it grows, starting with the last 10 lines
$ touch file #===> Create or update file
$ rm file #===> Deleting the file
$ rm -r dir #===> Deleting the directory
$ rm -f file #===> Force to remove the file
$ rm -rf dir #===> Force to remove the directory dir
$ cp file1 file2 #===> Copy the contents of file1 to file2
$ cp -r dir1 dir2 #===> Copy dir1 to dir2;create dir2 if not present
$ tar #===> Zip/unzip a file
PROCESS MANAGEMENT COMMANDS
$ ps #===> Display the currently working processes
$ top #===> Display all running process
$ pkill pattern #===> Kill all processes matching the pattern
$ bg #===> List stopped/background jobs, resume a stopped job in the background
$ fg #===> Bring the most recent job to foreground
$ fg n #===> Bring job n to the foreground
SEARCHING COMMANDS
$ grep pattern file #===> Search for pattern in file
$ grep -r pattern dir #===> Search recursively for pattern in dir
$ command | grep pattern #===> Search pattern in the output of a command
$ locate file_name #===> Find all instances of file_name
$ find . -name filename #===> Search in the current directory and below it, for files
# and directories with names starting with filename
$ pgrep pattern #===> Search all named processes that match with the pattern and return their ID
SYSTEM INFO COMMANDS
$ date #===> Show current date and time
$ cal #===> Show this month's calender
$ uptime #===> Show current uptime
$ w #===> Display who is online
$ whoami #===> Who you are logged in as
$ finger user #===> Display information about the user
$ uname -a #===> Show kernel information
$ cat /proc/cpuinfo #===> CPU information
$ cat proc/meminfo #===> Memory information
$ man command #===> Show the manual for the 'command' command
$ df #===> Show the disk usage
$ du #===> Show directory space usage
$ free #===> Show memory and swap usage
$ whereis app #===> Show possible locations of app
$ which app #===> Show which application will run by default
NETWORKING
$ ping host #===> Ping host and output results
$ whois domain #===> Get whois information for domains
$ dig domain #===> Get DNS information for domain
$ dig -x host #===> Reverse lookup host
$ wget file #===> Download file
$ wget -c file #===> Continue a stopped download
SHORTCUTS
$ ctrl+c #===> Halts the current command
$ ctrl+z #===> Stops the current command, resume with "fg" in the foreground or "bg" in the background
$ ctrl+d #===> Logout the current session, similar to exit
$ ctrl+w #===> Erase one word in the current line
$ ctrl+u #===> Erase the whole line
$ ctrl+r #===> Type to bring up a recent command
$ !! #===> Repeat the last command
$ exit #===> Logout the current session