There are well over 100 Unix commands shared by the Linux kernel and other Unix-like operating systems. If you are interested in the commands frequently used by Linux sysadmins and power users, you’ve come to the place. Recently, I published a five-part series covering commands often used by Linux sysadmins.
Below I’ve listed the 90 commands covered and links to each of the five posts in this series. Some of the commands listed include links to related articles. There are also thousands of commands available if we include downloadable software and scripts, such as bpytop (pictured below). However, for this article’s purpose, we will cover mostly Unix commands used on Linux by sysadmins and power users. If you find this page useful, let me know if you’d like to see similar posts in the future.
- ip – from Iproute2, a collection of utilities for controlling TCP/IP networking and traffic control in Linux.
- ls – list directory contents.
- df – display disk space usage.
- du – estimate file space usage.
- free – display memory usage.
- scp – securely Copy Files Using SCP, with examples.
- find – locates files based on some user-specified criteria.
- ncdu – a disk utility for Unix systems.
- pstree – display a tree of processes.
- last – show a listing of last logged-in users.
- w – show a list of currently logged-in user sessions.
- grep – Search a file for a pattern of characters, then display all matching lines.
- uptime – shows system uptime and load average.
- top – shows an overall system view.
- vmstat – shows system memory, processes, interrupts, paging, block I/O, and CPU info.
- htop – interactive process viewer and manager.
- dstat – view processes, memory, paging, I/O, CPU, etc., in real-time. All-in-one for vmstat, iostat, netstat, and ifstat.
- iftop – network traffic viewer.
- nethogs – network traffic analyzer.
- iotop – interactive I/O viewer. Get an overview of storage r/w activity.
- iostat – for storage I/O statistics.
- netstat – for network statistics.
- ss – utility to investigate sockets.
- atop – For Linux server performance analysis.
- Glances and nmon – htop and top Alternatives:
- ssh – secure command-line access to remote Linux systems.
- sudo – execute commands with administrative privilege.
- cd – directory navigation.
- pwd – shows your current directory location.
- cp – copying files and folders.
- mv – moving files and folders.
- rm – removing files and folders.
- mkdir – create or make new directories.
- touch – used to update the access date and modification date of a computer file or directory.
- man – for reading system reference manuals.
- apropos – Search man page names and descriptions.
- rsync – remote file transfers and syncing.
- tar – an archiving utility.
- gzip – file compression and decompression.
- bzip2 – similar to gzip. It uses a different compression algorithm.
- zip – for packaging and compressing (to archive) files.
- locate – search files in Linux.
- ps – information about the currently running processes.
- Making use of Bash scripts. Example: ./bashscript.sh
- cron – set up scheduled tasks to run.
- nmcli – command-line tool for controlling NetworkManager.
- ping – send ICMP ECHO_REQUEST to network hosts.
- traceroute – check the route packets take to a specified host.
- mtr – network diagnostic tool.
- nslookup – query Internet name servers (NS) interactively.
- host – perform DNS lookups in Linux.
- dig – DNS lookup utility.
- wget – retrieve files over HTTP, HTTPS, FTP, and FTPS.
- curl – transferring data using various network protocols. (supports more protocols than wget)
- dd – convert and copy files.
- fdisk – manipulate the disk partition table.
- parted – for creating and manipulating partition tables.
- blkid – command-line utility to locate/print block device attributes.
- mkfs – build a Linux file system.
- fsck – tool for checking the consistency of a file system.
- whois – client for the whois directory service.
- nc – command-line networking utility. (Also, see 60 Linux Networking commands and scripts.)
- umask – set file mode creation mask.
- chmod – change the access permissions of file system objects.
- chown – change file owner and group.
- chroot – run command or interactive shell with a special root directory.
- useradd – create a new user or update default new user information.
- userdel – used to delete a user account and all related files.
- usermod – used to modify or change any attributes of an existing user account.
- vi – text editor.
- cat – display file contents.
- tac – output file contents, in reverse.
- more – display file contents one screen/page at a time.
- less – similar to the more command with additional features.
- tail – used to display the tail end of a text file or piped data.
- dmesg – prints the message buffer of the kernel ring.
- journalctl – query the systemd journal.
- kill – terminate a process.
- killall – Sends a kill signal to all instances of a process by name.
- sleep – suspends program execution for a specified time.
- wait – Suspend script execution until all jobs running in the background have been terminated.
- nohup – Run Commands in the Background.
- screen – hold a session open on a remote server. (also a full-screen window manager)
- tmux – a terminal multiplexer.
- passwd – change a user’s password.
- chpassword – allows users to change the password for various user accounts.
- mount / umount – provides access to an entire filesystem in one directory.
- systemctl – central management tool for controlling the init system.
- clear – clears the screen of the terminal.
- env -Run a command in a modified environment.
- cheat – allows you to create and view interactive cheatsheets on the command line.”
- tldr – Collaborative cheatsheets for console commands.
- bashtop – the ‘cool’ top alternative.
- bpytop – Python port of bashtop.
- btop – C++ version and continuation of bashtop and bpytop.
- nload – a super simple, command-line network interface monitoring tool.
- history – used to view the previously executed commands.
- sar – collects, reports, and saves system activity information, including CPU, memory, disk, and network usage.
Root Directory (/): At the top of the hierarchy is the root directory, represented by a single forward slash /. This is the starting point for the entire file system.
Directories (Folders): Directories are containers that can hold files and other directories. They are analogous to folders in a graphical file manager. You can navigate to different directories using the cd command.
Current Directory (.) and Parent Directory (..): In Linux, there are two special directory references you can use with cd:
. (dot): Represents the current directory. You can use it to specify your current location explicitly.
.. (dot-dot): Represents the parent directory of the current directory. It allows you to move up one level in the file system hierarchy.
Absolute and Relative Paths: When using cd, you can provide paths that are either absolute or relative:
Absolute path: Starts from the root directory and specifies the complete path to a directory. For example, /home/user/documents.
Relative path: Specifies a path relative to your current directory. For instance, if you’re in /home/user, you can use cd documents to navigate to the “documents” directory, assuming it exists in your current directory.
Home Directory (~): The tilde (~) is a shorthand notation for your home directory. For example, cd ~ will take you to your home directory, regardless of your current location.
Path Separators: Linux uses forward slashes (/) as path separators. For example, /var/www/html is a path to a directory structure.
Tab Completion: When using the cd command, you can often take advantage of tab completion by pressing the Tab key. This feature helps you quickly complete directory and file names, reducing typing errors.
Before we delve into examples, let’s first understand the basic syntax of the cd command:
cd [directory]
[directory]:
This is an optional argument that specifies the directory you want to change to. If you don’t provide a directory, cd will take you to your home directory. Now, let’s explore some common use cases.
Example 1: Moving to Your Home Directory
cd
Running cd without any arguments will take you to your home directory. This is a quick way to get back to your home folder, no matter where you are in the file system. Example 2: Navigating to a Specific Directory
cd /path/to/directory
Replace /path/to/directory with the actual path to the directory you want to go to. This allows you to jump directly to a specific location in the file system. Example 3: Moving Up One Directory
cd ..
The .. notation is used to move up one directory level. This is handy when you want to navigate to the parent directory of your current location. Example 4: Moving to Your Previous Directory
cd –
The - (dash) argument takes you to your previous directory. This can be incredibly useful when you need to switch back and forth between two directories. Example 5: Using Tilde for User Directories
cd ~/Documents
The tilde (~) represents your home directory. You can use it to specify paths relative to your home directory. In this example, we’re navigating to the “Documents” directory within your home folder. Conclusion
The cd command is a fundamental tool for navigating the Linux file system. Whether you need to quickly jump to your home directory, move to a specific location, or navigate between directories efficiently, cd has you covered. By mastering the cd command, you’ll become more proficient at working with the command line in Linux.
Copyright (C) 2024 by Tyrone Hills All rights reserved [email protected].