Best Common Linux Commands In 2024

The common linux commands

In this post, we have tried to mention all common linux commands that are relevant to the linux administrator and dba to perform day-to-day activities by common linux commands with syntax, examples, definitions, and descriptions.

Here are some of the top common linux commands relevant for Linux administrators and dba, along with their syntax, examples, definitions, and descriptions:

ls (List Directory Contents):
Definition: To list the contents of a directory.
Description: This ls command is used to view the files and directories within a specified directory. It can display such things as permissions, ownership, size, and modification time.
Syntax: ls [options] [directory]
Example: ls -l /home

pwd (Print Working Directory):
Definition: To display the current working directory.
Description: This pwd command shows the present working directory and to know their current location in the file system.
Syntax: pwd
Example: pwd

cd (Change Directory):
Definition: To change the current working directory.
Description: This cd command is used to change the current working directories. To specify the directory path after cd.
Syntax: cd [directory Name]
Example: cd /u01

mkdir (Make Directory):
Definition: To create a new directory.
Description: This mkdir command is used to create a new directory with the specified directory name in the current working directory.
Syntax: mkdir [directory_name]
Example: mkdir my_directory

rmdir (Remove Directory):
Definition: To delete an empty directory.
Description: This rmdir command is used to remove specified empty directory name from the file system. It wouldn’t delete directories that contain files.
Syntax: rmdir [directory_name]
Example: rmdir empty_directory

touch (Create Empty File):
Definition: To create an empty file or update the access and modification timestamps of an existing file.
Description: This touch command is used to create a new empty file with the specified name.
Syntax: touch [filename]
Example: touch filename.txt

cp (Copy Files and Directories):
Definition: To copy files and directories.
Description: This cp command is used to copy files and directories from a source to a destination location.
Syntax: cp [options] [source] [destination]
Example: cp control.ctl /u02

mv (Move or Rename Files and Directories):
Definition: To move or rename files and directories.
Description: This mv command is used to move files and directories from one to target location or to rename them. It is also used for moving files and directories to target location.
Syntax: mv [options] [source] [destination]
Example: mv control.ctl /u01

rm (Remove Files or Directories):
Definition: To delete files and directories.
Description: This is very important command to use to delete files and directories from the file system and deleted files cannot be easily recovered.
Syntax: rm [options] [file1] [file2] …
Example: rm control.ctl

cat (Concatenate and Display File Contents):
Definition: To display the contents of a file.
Description: This cat command is used to display the contents of file or more files and it’s commonly used to view the contents of the files.
Syntax: cat [file]
Example: cat file.txt

more (Display File Content Page by Page):
Definition: To display the contents of a file page by page.
Description: This more command is similar to cat but displays the file content one page at a time, allowing users to scroll through large files easily.
Syntax: more [file]
Example: more file.txt

less (Display File Content Page by Page with Navigation):
Definition: To display the contents of a file.
Description: This Less is similar to more but provides more advanced features, such as scrolling backward and forward through the file.
Syntax: less [file]
Example: less file.txt

head (Display First Few Lines of a File):
Definition: To display the first few lines of a file.
Description: This head command is used to display the first few lines of a file. It is very useful for quickly inspecting of large files (by default, the first 10 lines).
Syntax: head [options] [file]
Example: head -n 10 file.txt

tail (Display Last Few Lines of a File):
Definition: To display the last few lines of a file.
Description: This tail command is used to display the last few lines (by default, the last 10 lines) of a file.
Syntax: tail [options] [file]
Example1: tail -n 5 file.txt
Example2: tail -n 50 file.txt
Example3: tail -f file.txt

find (Search for Files and Directories):
Definition: To search for files and directories that match specified criteria.
Description: This find command is used to search for files and directories within a specified directory, such as name, size, permissions, and modification time.
Syntax: find [directory] [options] [expression]
Example: find /u01 -name “.txt” find /u01 -name “control*”

wc (Word Count):
Definition: To display the number of lines, words, and characters in a file.
Description: This wc command is used to count the number of lines, words, and characters in one or more files.
Syntax: wc [options] [file(s)]
Example: wc -l file.txt

chmod (Change File Permissions):
Definition: To change the permissions of a file or directory.
Description: This chmod command is used to change the permissions (read, write, execute (rwx)) of files and directories.
Syntax: chmod [options] mode file(s)
Example1: chmod +x myscript.sh
Example2: chmod 775 Hot_backup.sh

chown (Change File Ownership):
Definition: To change the owner and group of a file or directory.
Description: This chown command is used to change the owner and group of a file or directory.
Syntax: chown [options] user:group file(s)
Example: chown oracle:oinstall spfile.bkp

passwd (Change User Password):
Definition: To change the password of a user account.
Description: This passwd command allows users to change their passwords. it changes the password of the current user.
Syntax: passwd [username]
Example: passwd oracle

whoami (Display Current User):
Definition: To display the username of the current user.
Description: This whoami command is simply displays the username of the currently logged-in user.
Syntax: whoami
Example: whoami

history (View Command History):
Definition: To display all previously executed commands.
Description: This history command shows all previously executed commands in the current shell session.
Syntax: history [options]
Example: history

man (Manual Pages):
Definition: To display the manual page for a specified command.
Description: This man command is used to view the manual pages for various commands in Linux.
Syntax: man [command]
Example: man ls

df (Disk Free):
Definition: To display information about disk space usage.
Description: This df command is used to show the amount of disk space used and available on filesystem.
Syntax: df [options] [directory]
Example: df -h

du (Disk Usage):
Definition: To display disk usage by files and directories.
Description: This du command is used to calculate and display the disk usage of files and directories.
Syntax: du [options] [directory]
Example: du -sh /u01

ping (Check Network Connectivity):
Definition: To check network connectivity.
Description: This ping command is used to test network connectivity to a specified host.
Syntax: ping [options] host
Example1: ping google.com
Example2: ping 8.8.8.8 (IP Address)

ifconfig (Interface Configuration):
Definition: To display and configure network interfaces.
Description: This ifconfig command is used to show information about network interfaces, such as IP addresses, netmasks, and interface status.
Syntax: ifconfig [interface] [options]
Example: ifconfig eth0

uname (Display System Information):
Definition: To display information about the system.
Description: This uname command is used to display system informations such as the kernel name, hostname, kernel release, kernel version, machine architecture, and operating system.
Syntax: uname [options]
Example: uname -a

date (Display Current Date and Time):
Definition: To display the current date and time.
Description: This date command is used to display the current date and time and to set the system date and time also.
Syntax: date [options]
Example: date

shutdown (Shutdown or Restart the System):
Definition: To shut down or restart the system.
Description: This shutdown command is used to reboot the system by specifying options like -h for halt or -r for reboot.
Syntax: shutdown [options]
Example: shutdown -h now

reboot (Reboot the System):
Definition: To reboot the system.
Description: This reboot command is used to restart the system.
Syntax: reboot [options]
Example: reboot

ps (Process Status):
Definition: To display information about active processes.
Description: This ps command is used to display the currently running processes on the system.
Syntax: ps [options]
Example: ps aux

top (System Monitoring Tool):
Definition: To display real-time system resource usage.
Description: This top command is used to provide real-time system resource usage, CPU, memory, and process information.
Syntax: top
Example: top

kill (Terminate Processes):
Definition: To terminate a process.
Description: This kill command is used to kill a specified process.
Syntax: kill [options] [PID]
Example: kill -9 1234

tar (Tape Archive):
Definition: To extract tar archives.
Description: Tar is used to bundle multiple files and directories into a single archive file, often compressed with gzip.
Syntax: tar [options] [archive_name] [files/directories]
Example: tar -czvf archive.tar.gz /u01

gzip (GNU Zip):
Definition: To compress or decompress files using gzip.
Description: The gzip is a compression tool used to reduce the size of files by compressing them.
Syntax: gzip [options] [file(s)]
Example: gzip file.txt

grep (Search Text in Files):
Definition: To search for a specific pattern.
Description: This grep command is used to search for text patterns files.
Syntax: grep [options] pattern [file(s)]
Example: grep “ora-error” alert.log

sed (Stream Editor):
Definition: To process text using specified commands.
Description: This Sed command is a powerful editor for filtering and transforming text and it performs task like search and replace.
Syntax: sed [options] ‘command’ [file(s)]
Example: sed ‘s/u01/g’ myfile.txt

awk (Text Processing Tool):
Definition: To process and analyze text files using specified patterns.
Description: This Awk is a processing tool for extracting and manipulating data in text files.
Syntax: awk [options] ‘pattern {action}’ [file(s)]
Example: awk ‘{print $1}’ myfile.txt

crontab (Cron Table):
Definition: To schedule tasks to run at specified times.
Description: This crontab command is used to create, edit, and manage cron jobs, which are on scheduled tasks that run automatically at predefined intervals.
Syntax: crontab [options]
Example1: crontab -e
Example2: crontab -l

userdel (Delete User Account):
Definition: To delete a user account from the system.
Description: This userdel command is used to remove or delete a user account from the system.
Syntax: userdel [options] username
Example: userdel oracle

groupadd (Add Group):
Definition: To create a new group on the system.
Description: This groupadd command is used to create a new group on the system and manage access..
Syntax: groupadd [options] groupname
Example: groupadd oinstall

groupdel (Delete Group):
Definition: To delete a group from the system.
Description: This groupdel command is used to remove or delete a group from the system but it does not delete files owned by the group.
Syntax: groupdel [options] groupname
Example: groupdel oinstall

iptables (IP Packet Filtering):
Definition: To manage firewall rules and packet filtering.
Description: This iptables command is used to configure and manage firewall rules in Linux.
Syntax: iptables [options] [table] [command] [chain] [options]
Example: iptables -A INPUT -p tcp –dport 22 -j ACCEPT

systemctl (Systemd Service Control):
Definition: To control systemd services and manage the system.
Description: This Systemctl is for managing systemd services and controlling the system’s behavior like start, stop, enable, disable, and manage the status of services.
Syntax: systemctl [options] [command] [unit]
Example1: systemctl start sshd
Example2: systemctl stop sshd

These above common linux commands cover a wide range of tasks performed by Linux administrators, including managing users and groups, configuring network settings, controlling system services, and more.

Read More.

Useful Linux Commands For DBA

Basic Linux commands for Oracle DBA With Examples

Best Linux Commands For Beginners

Top 10 Linux Commands with Examples

Top 20 Linux Commands with Examples

Top 30 Linux Commands with Examples

Top 40 Linux Commands with Examples

Top 50 Linux Commands with Examples

Top 100 Linux Commands with Examples, Definitions, and descriptions

Leave a Comment