Linux commands are integral for managing and operating a Linux-based system.
Below is a list of some commonly used Linux commands along with a brief description of their functionality:
ls
– Lists files and directories in the current directory.
ls
cd
– Changes the current directory.
cd /path/to/directory
pwd
– Prints the path of the current directory.
pwd
mkdir
– Creates a new directory.
mkdir new_directory
rmdir
– Removes a directory.
rmdir directory_name
touch
– Creates an empty file.
touch new_file.txt
rm
– Removes files or directories.
rm file.txt
cp
– Copies files or directories.
cp source.txt destination.txt
mv
– Moves or renames files or directories.
mv old_name.txt new_name.txt
cat
– Concatenates and displays file content.cat file.txt
more
/less
– Displays file content page by page.less file.txt
head
/tail
– Displays the beginning/end of a file.head file.txt tail file.txt
grep
– Searches text using patterns.grep "pattern" file.txt
find
– Finds files or directories.find / -name "file.txt"
who
– Shows who is logged on.who
ps
– Shows the current processes.ps -aux
kill
– Terminates processes.kill -9 process_id
tar
– Archives files.tar -cvf archive.tar /path/to/directory
gzip
/gunzip
– Compresses or decompresses files.gzip file.txt gunzip file.txt.gz
chmod
– Changes file permissions.chmod 755 file.txt
chown
– Changes file ownership.bash chown username:group file.txt
These commands form the basic toolkit for navigating and managing a Linux system. They are executed in the terminal and are case-sensitive. The -h
flag (e.g., ls -h
, df -h
) often provides human-readable output, and the --help
flag (e.g., ls --help
) provides usage information.
uname
– Displays system information.uname -a
df
– Shows disk usage.df -h
du
– Shows file and directory space usage.du -sh /path/to/directory
ifconfig
/ip
– Displays or configures network interface parameters.ifconfig ip addr
netstat
– Shows network connections, routing tables, and interface statistics.netstat -an
ss
– Another utility to investigate sockets.ss -tuln
ping
– Tests network connectivity.ping google.com
traceroute
/tracepath
– Traces the route packets take to a network host.traceroute google.com tracepath google.com
curl
/wget
– Downloads files from the web.curl -O https://example.com/file.txt wget https://example.com/file.txt
top
/htop
– Displays dynamic real-time view of system processes.top htop
free
– Shows memory usage.free -m
whoami
– Displays the username of the current user.whoami
id
– Displays user and group information for a user.id
nano
/vi
/vim
– Text editors.nano file.txt vi file.txt vim file.txt
alias
– Creates an alias for a command.alias ll='ls -la'
history
– Shows command history.history
crontab
– Scheduling jobs.crontab -e
awk
– Text and data extraction and reporting.awk '{print $1}' file.txt
sed
– Stream editor for filtering and transforming text.bash sed 's/old/new/' file.txt
These commands and utilities further extend your ability to manage and interact with Linux systems. They help in troubleshooting, system maintenance, network management, and other crucial system administration tasks. Each command usually has a man page which provides more detailed information on how to use it.
You can access the man page of a command by typing man
followed by the command name, like so:
man ls
apt
/apt-get
/dpkg
– Package management commands for Debian-based systems.apt update apt-get install package_name dpkg -i package_name.deb
yum
/rpm
/dnf
– Package management commands for Red Hat-based systems.yum install package_name rpm -i package_name.rpm dnf install package_name
zip
/unzip
– Compressing and decompressing files.zip archive_name.zip file1 file2 unzip archive_name.zip
passwd
– Changing user password.passwd
useradd
/userdel
– Adding or deleting users.useradd username userdel username
groupadd
/groupdel
– Adding or deleting groups.groupadd groupname groupdel groupname
mount
/umount
– Mounting and unmounting file systems.mount /dev/sda1 /mnt umount /mnt
fsck
– File system check.fsck /dev/sda1
shutdown
/reboot
– Shutting down or rebooting the system.shutdown -h now reboot
lsof
– Listing open files.lsof
date
– Displays or sets the system date and time.date
cal
– Displays a calendar.cal
uptime
– Shows how long the system has been running.uptime
hostname
– Shows or sets the system’s hostname.hostname
nc
(netcat) – Networking utility for reading from and writing to network connections.nc -l 1234
dig
/nslookup
– DNS lookup utilities.dig example.com nslookup example.com
iptables
– Administration tool for IPv4/IPv6 packet filtering and NAT.iptables -L
sar
– System activity reporter.sar
cut
– Removes sections from each line of files.cut -d' ' -f1 file.txt
sort
– Sorts lines of text files.bash sort file.txt
These commands further enrich the toolkit of a Linux user or system administrator. They cover a broad range of functionalities including user management, package management, system and network diagnostics, file operations, and many other essential aspects of system operation and maintenance.
uniq
– Filters out adjacent matching lines in input.sort file.txt | uniq
find
– Searches for files in a directory hierarchy.find /path -name filename
grep
– Searches text using patterns.grep "pattern" file.txt
tar
– Archives files.tar -cvf archive.tar /path/to/directory
head
/tail
– Outputs the first/last part of files.head -n 10 file.txt tail -n 10 file.txt
touch
– Creates empty files.touch file.txt
chmod
/chown
– Changes file permissions and ownership.chmod 755 file.txt chown user:group file.txt
locate
– Finds files by name.locate filename
kill
/pkill
/killall
– Sends signals to processes.kill 12345 pkill process_name killall process_name
ps
– Shows process status.ps aux
jobs
– Lists active jobs.jobs
fg
/bg
– Puts jobs in the foreground/background.fg %1 bg %1
strings
– Prints the strings of printable characters in files.strings filename
xargs
– Builds and executes command lines from standard input.find /path -type f -name "*.txt" | xargs rm
diff
– Compares files line by line.diff file1.txt file2.txt
comm
– Compares two sorted files line by line.bash comm file1.txt file2.txt
These additional commands cover file and text manipulation, process management, and other functionalities that are crucial for both basic and advanced system operations and troubleshooting. The Linux command line is a powerful tool that offers a vast array of utilities and commands for various tasks and is an essential skill for system administrators and power users.
I have covered a broad spectrum of commonly used Linux commands. The list includes commands for file management, user and group management, package management, network diagnostics, system monitoring, and process control among others.
Here are a few more commands related to disk management and monitoring:
df
– Reports file system disk space usage.df -h
du
– Estimates file space usage.du -sh /path/to/directory
fdisk
– Manipulates disk partition table.fdisk /dev/sda
mkfs
– Creates a file system on a device.mkfs -t ext4 /dev/sda1
swapon
/swapoff
– Enables/disables devices and files for paging and swapping.swapon /dev/sda2 swapoff /dev/sda2
hdparm
– Get/set SATA/ATA disk parameters.hdparm -I /dev/sda
lsblk
– Lists information about all available or the specified block devices.lsblk
lshw
– Lists hardware information.lshw -C disk
smartctl
– Controls the Self-Monitoring, Analysis and Reporting Technology (SMART) system built into most modern ATA/SATA, SCSI/SAS, and NVMe disks.smartctl -a /dev/sda
iostat
– Reports Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.bash iostat
These commands are helpful in managing and monitoring disk space, partitioning disks, creating file systems, and obtaining detailed hardware and disk information. The proper use of these commands is essential for maintaining system performance, troubleshooting issues, and ensuring data integrity.
Here are some more commands related to text processing and searching, as well as a few other miscellaneous commands:
sed
– Stream editor for filtering and transforming text.echo "hello world" | sed 's/world/universe/'
awk
– Pattern scanning and text/data extraction.echo -e "one two\nthree four" | awk '{print $2}'
sort
– Sorts lines of text files.sort file.txt
paste
– Merges lines of files.paste file1.txt file2.txt
cut
– Removes sections from each line of files.cut -d':' -f1 /etc/passwd
tr
– Translates or deletes characters.echo "hello world" | tr ' ' '_'
column
– Formats text input into a table.column -t file.txt
alias
– Creates an alias for a command.alias ll='ls -la'
unalias
– Removes an alias.unalias ll
watch
– Executes a program periodically, showing output fullscreen.watch df -h
who
– Shows who is logged on.who
w
– Shows who is logged on and what they are doing.w
uptime
– Shows the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.uptime
history
– Shows the command history.bash history
These commands further illustrate the versatility and the power of the command line interface in Unix-like operating systems, enabling users to process text, monitor system status, manage their command history, and even customize their command set with aliases.