This is @ryusei__46 here.
For both personal reference and to help others, I'm going to compile a list of my most frequently used—and easily forgettable—Linux commands.
While I rarely forget the commands I frequently use for server management, others tend to fade from my memory if I don't use them regularly.
Every time this happens, searching online becomes inefficient and time-consuming.
Fortunately, we now have powerful tools like Chat GPT and other useful generative AIs available these days, so I'm increasingly relying on them for command suggestions. While Chat GPT is great, "phind" is actually quite remarkable. It's a programming-focused generative AI that, best of all, offers free access to GPT-4. I highly recommend giving it a try.
That said, I've digressed a bit—let's get to the command list. The commands below are all from my server environment running Ubuntu 22.04.
This article will be updated incrementally as I encounter more commands I'm likely to forget when using them regularly.
Since every server administrator knows and uses the essential daily commands, I've intentionally omitted those from this list.
ls command: List directory contents
This is probably one of the most fundamental Linux commands, but by adding various options, you can make it much more readable. Below is an example of the ls command with options that I typically use:
$ ls -laF --group-directories-first --color -hWhen executed, items are displayed in the following order: "Permissions", "Owner User", "Owner Group", "Size with unit", "Last Modified Date/Time", and "File or Directory Name (for directories, appends /; for text files, color-coded)", grouped with directories appearing above files. This display method mirrors Windows Explorer, making it instantly intuitive and easy to understand.
However, since the options become quite lengthy and entering them repeatedly would be tedious, it's better to simply register the command as an alias.
$ alias myls="ls -laF --group-directories-first --color -h"Now, you can run myls in the terminal to display the output in the specified format. Replace myls with any desired string—just be cautious not to use a name that conflicts with existing commands, as your alias will take precedence. If you accidentally create an alias for a command that already exists, your custom command will be executed instead.
To remove an alias, execute unalias [command].
Note that aliases are lost when you log out, so you need to add the above command to your ~/.bashrc file to run it automatically upon login.
htop Command: Monitoring System Resources
htop is an interactive system monitoring tool for Linux and Unix-like systems, serving as an alternative to the top command. This tool displays system CPU usage, memory usage, and swap usage in bar charts, along with detailed process information. It is significantly more feature-rich than the built-in top command in Linux distributions.
Unless you have specific reasons not to, you should use the htop command instead. You can install the htop command using the following command:
$ sudo apt install htopThe interface has also been made more graphical, with function keys displayed at the bottom of the screen allowing various operations. Features like filters, search functionality, and process termination are particularly convenient.
Especially for operations like forcefully terminating processes - previously you would need to locate processes using the ps command and then terminate them with the kill command, but now I handle everything using htop.
lsof command: Checking if a specified port number is in use
The lsof command is used to list information about processes that have open access to specific files or port numbers. If you want to view processes opened by a root user or other users, you must run it with sudo or as the root user.
To check which processes are using a specific directory or file, execute lsof [directory path or file path]. For checking processes that have open access to a particular port number, use lsof -i:[port].
The output will appear in the following format:
// Verify if the standard SSH port 22 is open
$ sudo lsof -i:22
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 1004 root 3u IPv4 23201 0t0 TCP *:ssh (LISTEN)
sshd 1004 root 4u IPv6 23203 0t0 TCP *:ssh (LISTEN)
sshd 32619 root 4u IPv4 151342 0t0 TCP my-host:ssh->192.168.1.19:53733 (ESTABLISHED)
sshd 32728 root 4u IPv4 151342 0t0 TCP my-host:ssh->192.168.1.19:53733 (ESTABLISHED)ifconfig command: Checking network interfaces
The ifconfig command is a network interface configuration utility in Linux that enables users to set, manage, and query network interface parameters. This command is used to display current network configuration information, assign IP addresses, netmasks, or broadcast addresses to network interfaces, create interface aliases, configure hardware addresses, and enable or disable network interfaces.
I primarily use it for verifying IP addresses. While the ip a command can also perform this task, the ifconfig command provides a more organized and user-friendly display.
$ ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.4.6 netmask 255.255.255.0 broadcast 192.168.4.255
inet6 240b:12:8241:9205:c836:8dff:faf8:13d4 prefixlen 64 scopeid 0x0<global>
inet6 fe80::b826:8efe:fed5:13d0 prefixlen 64 scopeid 0x20<link>
ether ca:46:8e:f5:13:d0 txqueuelen 1000 (イーサネット)
RX packets 383025 bytes 81380768 (81.3 MB)
RX errors 0 dropped 24 overruns 0 frame 0
TX packets 139316 bytes 12230672 (12.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0inet represents IPv4, inet6 represents IPv6, and ether represents the MAC address.
screen command: Terminal session management
The screen command is a tool for managing multiple screen sessions. It allows you to start screen sessions containing multiple windows, effectively isolating processes running in your terminal. Additionally, screen enables you to switch between sessions and select which session to connect to.
I currently use this tool to manage web server processes and backend system operations. However, I plan to transition to PM2, an open-source process management tool for Node.js, in the near future.

PM2 is an advanced production process manager for Node.js applications with built-in load balancer, zero-downtime reload, startup scripts, monitoring, and microservice management features.
To start a new terminal session, execute the screen command. To detach from a session (exit without closing it), press Ctrl + A followed by D.
To list all currently running terminal sessions, use the screen -ls command. To attach to a specific screen session, use screen -r [screen ID].
To scroll through content within a connected screen session, enter copy mode by pressing Ctrl + A followed by [. You can then use the arrow keys to scroll through the screen. To exit copy mode, press the escape key on your keyboard.
bat command: Output file contents richly
The bat command was developed as an alternative to cat and less commands, automatically applying syntax highlighting and line numbers based on the file extension. It also incorporates the pager functionality of the less command, automatically entering pager mode when the content exceeds the screen width. Additionally, it includes string search functionality for searching within files.
A cat(1) clone with wings. Contribute to sharkdp/bat development by creating an account on GitHub.
This tool requires package installation.
$ sudo apt install bat -yTo view the file contents, run batcat [file path] in your terminal.
fd command: File search
The fd command was developed as an alternative to Linux's built-in find command. While it doesn't support all of find's functionality, being written in Rust allows it to operate significantly faster than the standard find command.
A simple, fast and user-friendly alternative to 'find' - sharkdp/fd
The following command is required to install the package.
$ sudo apt install fd-find -yTo run the fd command on Ubuntu, use fdfind instead of fd. The reason is explained in detail in the following GitHub issue:
Describe the bug you encountered: After installing fd-find either via apt on the command line or through Synaptic, I get: Command 'fd' not found, but can be installed with: sudo apt install fdclone...
To perform a simple recursive file search in the current directory, use fdfind [search string]. By default, the search string is interpreted as a regular expression pattern. Therefore, if you want to include metacharacters like . or ? from regular expressions in your search string, they must be escaped. To disable regular expression parsing and treat the search string as plain text, use the -g option.
By default, fdfind does not search hidden files or directories unless explicitly configured. To include them, use the -H option. Additionally, when searching files within a GitHub repository, the .gitignore file will be taken into account. To disable consideration of .gitignore files, use the -I option.
To search for files with specific extensions, use fdfind -e [extension] [search pattern].
To specify directories to search in, use fdfind [search pattern] [path].
By default, fdfind searches only for filenames, but you can also make it search full file paths by specifying the -p option.
These options can be combined freely to suit various use cases.
rg command: file content search
The rg command was developed as an alternative to Linux's built-in grep command. Like fd, it is also implemented in Rust and offers extremely fast performance. While fd searches files by name, rg searches for specific strings within files. In practice, you'll likely use this command more often. Additionally, it's commonly used in pipelines like [command] | rg "search pattern".
The official name of the command is "ripgrep," and its GitHub repository can be found at:
ripgrep recursively searches directories for a regex pattern while respecting your gitignore - BurntSushi/ripgrep
To simply search for files containing a specified string in the current directory, you can use rg [search string]. The `rg` command also treats input as regular expressions by default, so search strings containing metacharacters must be escaped.
To specify the target directory, use rg [search string] [path].
If you want to include files with specific file extensions in the search, use the --type option followed by the file type (e.g., rg [search string] [path] --type html). Conversely, to exclude certain file extensions, use the --type-not option (e.g., rg [search string] [path] --type-not html). To view a list of supported file types, run rg --type-list.
Like the fd command, the rg command defaults to ignoring hidden files and directories. To include them, use the --hidden option. As with fd, when searching GitHub repositories, the .gitignore file is considered. To disable this behavior, use the --no-ignore option. Specific to rg, you can also search the contents of binary files, enabled via the --text or -a option. Additionally, you can control whether to follow symbolic links using the --follow or -L option.


