Must-Know Linux Commands for Novice Users


Did you know that there are literally hundreds of Linux commands? Even on a bare-bones Linux server install there are easily over 1,000 different commands.
The interesting thing is that most people only need to use a very small subset of those commands. Below you’ll find a Linux commands that breaks down some of the most commonly used commands by category.
1 – SYSTEM INFORMATION
Display Linux system information
/uname -a
Display kernel release information
/uname -r
Show operating system information such as distribution name and version
/cat /etc/os-release
Show how long the system has been running + load
/uptime
Show system host name
/hostname
Display all local IP addresses of the host.
/hostname -I
Show system reboot history
/last reboot
Show the current date and time
/date
Show this month's calendar
/cal
Display who is online
/w
Who you are logged in as
/whoami
3 – PERFORMANCE MONITORING AND STATISTICS
Display and manage the top processes
/top
Display virtual memory statistics
/vmstat 1
Display I/O statistics
/iostat 1
List all open files on the system
/lsof
List files opened by user
lsof -u user
Display free and used memory ( -h for human readable, -m for MB, -g for GB.)
/free -h
3 – USER INFORMATION AND MANAGEMENT
Display the user and group ids of your current user.
/id
Display the last users who have logged onto the system.
/last
Show who is logged into the system
.
/who
Show who is logged in and what they are Display the user and group ids of your current user.
/id
Display the last users who have logged onto the system.
/last
Show who is logged into the system.
/who
Create a group named "devops".
/groupadd devops
Create an account named suraj, with a comment of "Suraj Topare" and create the user's home directory.
/useradd -c "Suraj Topare" -m suraj
Delete the suraj account.
/userdel suraj
Add the suraj account to the devops group
/usermod -aG devops suraj
4 – FILE AND DIRECTORY COMMANDS
List all files in a long listing (detailed) format
/ls -al
Display the present working directory
/pwd
Create a directory
/mkdir directory
Remove (delete) file
/rm file
Remove the directory and its contents recursively
/rm -r directory
Force removal of file without prompting for confirmation
/rm -f file
Copy file1 to file2
/cp file1 file2
Copy source_directory recursively to destination. If destination exists, copy source_directory into destination, otherwise create destination with the contents of source_directory.
/cp -r source_directory destination
Rename or move file1 to file2. If file2 is an existing directory, move file1 into directory file2
/mv file1 file2
Create an empty file or update the access and modification times of file.
/touch file
View the contents of file
/cat file
Display the first 10 lines of file
/head file
Display the last 10 lines of file
/tail file
Other useful command
🔍grep
Purpose
grep is used to search for patterns within files. It's incredibly useful for finding specific lines of text in large files.
Usage
grep 'pattern' filename
Example
To find all lines containing the word "error" in a log file, you can use:
grep 'error' logfile.txt
📊awk
Purpose
awk is a versatile programming language designed for pattern scanning and processing. It's perfect for extracting and manipulating data from text files.
Usage
awk 'pattern {action}' filename
Example
To print the second column of a file, you can use:
awk '{print $2}' filename
✂️ sed (Stream Editor)
Purpose
sed is a stream editor used for performing basic text transformations on an input stream (a file or input from a pipeline).
Usage
sed 's/old/new/' filename
Example
To replace the word "foo" with "bar" in a file, you can use:
Copy's/foo/bar/g' filename
Subscribe to my newsletter
Read articles from Suraj Topare directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
