In this blog post, I am trying to consolidate common commands available to manage the Linux Operating System. If you are looking for more detail info, you can either refer my previous Linux blog series(Part1 to 10) or use manual pages available for each commands using command -- man <command>
In Linux, there are several commands available to manage files, users, processes, networking, packages, and system settings. Below is a categorized list of essential Linux commands for various system management tasks:
1. File and Directory Management:
ls
: Lists files and directories.cd
: Changes the current directory.pwd
: Prints the current working directory.cp
: Copies files or directories.mv
: Moves or renames files or directories.rm
: Removes files or directories.mkdir
: Creates directories.rmdir
: Removes empty directories.find
: Searches for files in a directory hierarchy.touch
: Creates an empty file or updates the timestamp of an existing file.ln
: Creates hard and symbolic links.
2. File Permissions and Ownership:
chmod
: Changes file permissions.chown
: Changes file owner and group.chgrp
: Changes the group ownership of a file.umask
: Sets default file permissions.stat
: Displays detailed file or file system status, including permissions.
3. Process Management:
ps
: Displays information about active processes.top
orhtop
: Provides a dynamic view of running processes.kill
: Sends signals (e.g., to terminate) to processes.killall
: Kills all processes by name.nice
: Starts a process with a defined priority.renice
: Changes the priority of a running process.jobs
: Lists background jobs in the current shell.bg
: Resumes a job in the background.fg
: Brings a background job to the foreground.
4. Disk and Storage Management:
df
: Shows disk space usage.du
: Displays the amount of disk space used by files and directories.mount
: Mounts a file system.umount
: Unmounts a file system.fdisk
: Disk partitioning tool.parted
: Another disk partitioning tool with advanced features.mkfs
: Creates a file system on a disk partition.fsck
: File system consistency check and repair.lsblk
: Lists information about block devices.blkid
: Displays block device attributes (UUID, file system type).sync
: Synchronizes cached writes to persistent storage.
5. Networking:
ifconfig
: Configures network interfaces (deprecated, replaced byip
).ip
: Manages network interfaces, routing, and more.ping
: Tests network connectivity to a host.netstat
: Displays network connections, routing tables, and more (replaced byss
).ss
: Provides detailed socket statistics.traceroute
: Shows the path packets take to reach a host.nslookup
: Queries DNS to obtain domain name or IP address mapping.dig
: Performs DNS lookups.scp
: Securely copies files between hosts over the network.rsync
: Synchronizes files and directories between two locations over a network.iptables
: Configures firewall rules (replaced bynftables
on many systems).nft
: Manages packet filtering and network address translation (NAT).
6. User and Group Management:
useradd
: Adds a new user.usermod
: Modifies user account properties.userdel
: Deletes a user account.groupadd
: Adds a new group.groupmod
: Modifies a group.groupdel
: Deletes a group.passwd
: Changes the password for a user.who
: Shows who is logged in.w
: Shows detailed information about who is logged in and what they are doing.last
: Displays the last logins of users.
7. System Monitoring and Performance:
uptime
: Shows system uptime and load averages.free
: Displays memory usage.vmstat
: Reports virtual memory statistics.iostat
: Reports CPU and I/O statistics.sar
: Collects and reports system activity information.dmesg
: Prints kernel ring buffer messages (used for debugging hardware and kernel issues).lsof
: Lists open files and the processes using them.
8. Package Management:
- Debian-based systems (e.g., Ubuntu):
apt
: Manages packages (install, remove, update).apt-get
: Another package manager (more script-friendly).dpkg
: Manages individual Debian packages.
- Red Hat-based systems (e.g., RHEL, CentOS):
yum
: Manages packages (install, update, remove) (replaced bydnf
).dnf
: Next-generation package manager for Red Hat-based systems.rpm
: Manages individual RPM packages.
- Arch-based systems (e.g., Arch, Manjaro):
pacman
: Manages packages for Arch Linux and its derivatives.
9. Service and System Management:
systemctl
: Controls system services (start, stop, restart, enable, disable).service
: Manages services (older systems, replaced bysystemctl
).journalctl
: Views and manages systemd logs.crontab
: Schedules periodic tasks (cron jobs).at
: Schedules one-time tasks.shutdown
: Shuts down or restarts the system.reboot
: Reboots the system.
10. Security and Permissions:
sudo
: Executes commands as another user (usually root).su
: Switches to another user (e.g., root).gpasswd
: Administers/etc/group
(group management).iptables
/nft
: Configures firewall rules.semanage
: Manages SELinux settings (on systems with SELinux).
11. Archiving and Compression:
tar
: Archives multiple files into a single file and optionally compresses them.gzip
: Compresses files using the gzip algorithm.gunzip
: Decompresses files compressed withgzip
.zip
: Compresses files into a ZIP archive.unzip
: Extracts files from a ZIP archive.bzip2
/bunzip2
: Compresses and decompresses files using the bzip2 algorithm.xz
: Compresses files using the xz algorithm.
12. Backup and Recovery:
rsync
: Efficiently synchronizes files and directories between locations.dd
: Creates low-level copies of data, useful for backup and disk imaging.tar
: Archives files for backup purposes.cpio
: Copies files into and out of archives.