<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Linux on Sakurain Blog</title><link>https://zako.cam/en/tags/linux/</link><description>Recent content in Linux on Sakurain Blog</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Thu, 22 Oct 2026 04:55:52 +0800</lastBuildDate><atom:link href="https://zako.cam/en/tags/linux/index.xml" rel="self" type="application/rss+xml"/><item><title>Linux Commands</title><link>https://zako.cam/en/post/linux-command/</link><pubDate>Thu, 22 Oct 2026 04:55:52 +0800</pubDate><guid>https://zako.cam/en/post/linux-command/</guid><description>&lt;img src="https://imgbed.zako.cam/file/img/cover/1792634452620_133953527_p0.webp" alt="Featured image of post Linux Commands" /&gt;&lt;h2 id="commands-for-file-and-directory-operations-in-linux"&gt;&lt;a href="#commands-for-file-and-directory-operations-in-linux" class="header-anchor"&gt;&lt;/a&gt;Commands for File and Directory Operations in Linux&#10;&lt;/h2&gt;&lt;p&gt;File and directory operations in Linux mainly involve the following commands:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;ls&lt;/code&gt; - List directory contents&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;ls -l&lt;/code&gt; (list file or directory details in long format)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;cd&lt;/code&gt; - Change the current directory&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;cd /home&lt;/code&gt; (switch to the &lt;code&gt;/home&lt;/code&gt; directory)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;pwd&lt;/code&gt; - Display the path of the current directory&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;pwd&lt;/code&gt; (display the full path of the current working directory)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;mkdir&lt;/code&gt; - Create a new directory&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;mkdir new_dir&lt;/code&gt; (create a new directory named &lt;code&gt;new_dir&lt;/code&gt;)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;rmdir&lt;/code&gt; - Remove an empty directory&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;rmdir empty_dir&lt;/code&gt; (remove the empty directory named &lt;code&gt;empty_dir&lt;/code&gt;)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;rm&lt;/code&gt; - Remove files or directories&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;rm file.txt&lt;/code&gt; (remove the file named &lt;code&gt;file.txt&lt;/code&gt;)&lt;/li&gt;&#10;&lt;li&gt;Advanced usage: &lt;code&gt;rm -r dir&lt;/code&gt; (recursively remove the directory named &lt;code&gt;dir&lt;/code&gt; and its contents)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;cp&lt;/code&gt; - Copy files or directories&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;cp source.txt dest.txt&lt;/code&gt; (copy &lt;code&gt;source.txt&lt;/code&gt; to &lt;code&gt;dest.txt&lt;/code&gt;)&lt;/li&gt;&#10;&lt;li&gt;Advanced usage: &lt;code&gt;cp -r source_dir dest_dir&lt;/code&gt; (recursively copy a directory)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;mv&lt;/code&gt; - Move or rename files or directories&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;mv old_name.txt new_name.txt&lt;/code&gt; (rename &lt;code&gt;old_name.txt&lt;/code&gt; to &lt;code&gt;new_name.txt&lt;/code&gt;)&lt;/li&gt;&#10;&lt;li&gt;Advanced usage: &lt;code&gt;mv file.txt /home/user/&lt;/code&gt; (move &lt;code&gt;file.txt&lt;/code&gt; to the specified directory)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;touch&lt;/code&gt; - Create an empty file or modify a file&amp;rsquo;s timestamp&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;touch new_file.txt&lt;/code&gt; (create an empty file named &lt;code&gt;new_file.txt&lt;/code&gt;)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;chmod&lt;/code&gt; - Change the permissions of a file or directory&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;chmod 755 file.txt&lt;/code&gt; (change the permissions of &lt;code&gt;file.txt&lt;/code&gt; so that the owner can read, write, and execute, and the group and other users can read and execute)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;chown&lt;/code&gt; - Change the owner of a file or directory&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;chown user:group file.txt&lt;/code&gt; (change the owner of &lt;code&gt;file.txt&lt;/code&gt; to &lt;code&gt;user&lt;/code&gt; and the group to &lt;code&gt;group&lt;/code&gt;)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;These commands are the foundation of file and directory management in Linux systems, and mastering them is essential for effective system administration.&lt;/p&gt;&#10;&lt;h2 id="linux-process-management-commands"&gt;&lt;a href="#linux-process-management-commands" class="header-anchor"&gt;&lt;/a&gt;Linux Process Management Commands&#10;&lt;/h2&gt;&lt;p&gt;Process management in Linux mainly involves the following commands:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;ps&lt;/code&gt; - Display a snapshot of current processes&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;ps aux&lt;/code&gt; (display information about all processes)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;top&lt;/code&gt; - Dynamically display process information&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;top&lt;/code&gt; (display system process information in real time)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;htop&lt;/code&gt; (requires separate installation) - An enhanced version of the &lt;code&gt;top&lt;/code&gt; command, offering a friendlier interface and more information&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;htop&lt;/code&gt; (display system process information in real time with a friendlier interface)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;kill&lt;/code&gt; - Send a signal to a specified process&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;kill -9 1234&lt;/code&gt; (send the SIGKILL signal to the process with PID 1234, forcibly terminating it)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;pkill&lt;/code&gt; - Send a signal based on process name&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;pkill nginx&lt;/code&gt; (send the SIGTERM signal to all processes named nginx)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;killall&lt;/code&gt; - Kill all processes based on process name&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;killall nginx&lt;/code&gt; (kill all processes named nginx)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;nohup&lt;/code&gt; - Run a command in the background so that it continues even if the terminal is closed&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;nohup command &amp;amp;&lt;/code&gt; (run &lt;code&gt;command&lt;/code&gt; in the background and ignore the hangup signal)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;bg&lt;/code&gt; - Resume a job that was suspended in the background&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: first use &lt;code&gt;Ctrl+Z&lt;/code&gt; to suspend a process, then use the &lt;code&gt;bg&lt;/code&gt; command to continue running it in the background&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;fg&lt;/code&gt; - Bring a background job to the foreground to continue running&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;fg&lt;/code&gt; (bring the most recent background job to the foreground to continue running)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;jobs&lt;/code&gt; - Display all jobs in the current session and their status&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;jobs&lt;/code&gt; (list all jobs in the current session)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;nice&lt;/code&gt; - Set the priority of a new process&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;nice -n 10 command&lt;/code&gt; (start &lt;code&gt;command&lt;/code&gt; with priority 10)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;renice&lt;/code&gt; - Modify the priority of an existing process&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;renice 10 -p 1234&lt;/code&gt; (set the priority of the process with PID 1234 to 10)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;These commands are the foundation of process management in Linux systems; with them, you can effectively monitor, control, and adjust processes on the system.&lt;/p&gt;&#10;&lt;h2 id="linux-system-and-user-related-commands"&gt;&lt;a href="#linux-system-and-user-related-commands" class="header-anchor"&gt;&lt;/a&gt;Linux System and User-Related Commands&#10;&lt;/h2&gt;&lt;p&gt;Commands related to user and user group management in Linux systems include:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;useradd&lt;/code&gt; - Add a new user&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;useradd username&lt;/code&gt; (add a new user)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;userdel&lt;/code&gt; - Delete a user&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;userdel username&lt;/code&gt; (delete a user)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;usermod&lt;/code&gt; - Modify a user account&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;usermod -l newname oldname&lt;/code&gt; (change the username from oldname to newname)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;passwd&lt;/code&gt; - Change a user&amp;rsquo;s password&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;passwd username&lt;/code&gt; (change the password of the specified user)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;adduser&lt;/code&gt; (on some distributions) - A friendlier command for adding users than &lt;code&gt;useradd&lt;/code&gt;, usually offering more options&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;adduser newusername&lt;/code&gt; (add a new user interactively)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;groupadd&lt;/code&gt; - Add a new user group&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;groupadd groupname&lt;/code&gt; (add a new user group)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;groupdel&lt;/code&gt; - Delete a user group&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;groupdel groupname&lt;/code&gt; (delete a user group)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;groupmod&lt;/code&gt; - Modify a user group&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;groupmod -n newname oldname&lt;/code&gt; (change the user group name)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;gpasswd&lt;/code&gt; - Manage the &lt;code&gt;/etc/group&lt;/code&gt; file&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;gpasswd -a username groupname&lt;/code&gt; (add a user to a user group)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;id&lt;/code&gt; - Display a user&amp;rsquo;s UID and GID as well as the groups they belong to&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;id username&lt;/code&gt; (display information about the specified user)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;who&lt;/code&gt; - Display currently logged-in users&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;who&lt;/code&gt; (display all users currently logged in to the system)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;w&lt;/code&gt; - Display currently logged-in users and the commands they are running&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;w&lt;/code&gt; (display more detailed information about currently logged-in users)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;su&lt;/code&gt; - Switch user identity&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;su - username&lt;/code&gt; (switch to the specified user; the &lt;code&gt;-&lt;/code&gt; parameter means the user&amp;rsquo;s environment variables are also switched to those of the target user)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;sudo&lt;/code&gt; - Execute a command as another user (root by default)&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;sudo command&lt;/code&gt; (execute &lt;code&gt;command&lt;/code&gt; as root)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;chown&lt;/code&gt; - Change the owner of a file or directory&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;chown username:groupname file&lt;/code&gt; (change the owner and group of a file)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;chmod&lt;/code&gt; - Change the permissions of a file or directory&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;chmod 755 file&lt;/code&gt; (change file permissions)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;These commands are the foundation of user and user group management in Linux systems; with them, you can effectively manage user accounts and permissions on the system.&lt;/p&gt;&#10;&lt;h2 id="other-linux-commands"&gt;&lt;a href="#other-linux-commands" class="header-anchor"&gt;&lt;/a&gt;Other Linux Commands&#10;&lt;/h2&gt;&lt;ol&gt;&#10;&lt;li&gt;&lt;code&gt;echo&lt;/code&gt; - Display a string&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;echo “Hello,everyone!”&lt;/code&gt; (display the string “Hello,everyone!”&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;cal&lt;/code&gt; - Display a calendar&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;cal&lt;/code&gt; (display the calendar for the current month)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;date&lt;/code&gt; - Display and set the system date and time&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;date 08211550&lt;/code&gt; (change the time to August 21st, 3:50 PM)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;clear&lt;/code&gt; - Clear the screen&#10;&lt;ul&gt;&#10;&lt;li&gt;Usage example: &lt;code&gt;clear&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;</description></item></channel></rss>