Common SUSE Linux Operations
This section describes common operations performed on a SUSE Linux-based workstation. After learning this topic, you can improve the efficiency of the operations on the SUSE Linux OS.
Operating System Input Method
- Select M17N-zh-py or Wubi as the Chinese input method. To set the input method, click the keyboard at the lower right corner of the desktop and select M17N-zh-py or Wubi for simplified Chinese.
- To select English as the input method, click the keyboard icon at the lower right corner and select English/Keyboard.
Command Syntax
Do not use the numeric keypad because the Num Lock key may fail to work properly on the SUSE Linux operating system.
The command syntax is as follows:
Command Option Parameter
The SUSE Linux commands are case-sensitive. That is, the OS considers an uppercase letter and its corresponding lowercase letter two different letters. For example, when you want to use the command for displaying the files in a certain directory, the OS can correctly run the ls command, but it cannot run the Ls command because the Ls command is considered as an invalid system command. The options in the SUSE Linux commands are used to change the command execution method. Generally, the options start with a hyphen (-).
For example, if you need to query files and file details in the /opt directory, run the following command:
ls -al /opt
System Operations
Command |
Function |
---|---|
whoami |
Displays the current user name. |
id |
Displays the UID and GID of the current user. |
uname -a |
Displays the system version. |
free -m Or grep MemTotal /proc/meminfo |
Displays the memory information. |
fdisk Option |
Queries the number of disks. |
cat /proc/cpuinfo |
Displays the CPU information. |
ps -ef |
Displays all processes. |
ps -ef | grep java |
Displays all JAVA processes. |
man Command |
Queries the online help of a command. |
sync;sync;sync;sync shutdown -r now |
Restarts the SUSE Linux operating system. When you restart the operating system, the remote login user will exit. The restart takes 5 to 8 minutes. After the restart is complete, you need to log in to the server again. |
sync;sync;sync;sync shutdown -h now |
Shuts down the SUSE Linux operating system. |
Network Operations
Command |
Function |
---|---|
ifconfig |
Queries the IP address configuration. |
netstat -an |
Queries all enabled ports. |
netstat -anp | grep Port number Or lsof -i :Port number |
Queries the information about a port. |
route |
Queries the route information. |
route add -net Destination subnet address netmask Destination subnet mask dev Egress NIC name An example is as follows: route add -net 10.224.0.0 netmask 10.240.0.0 dev eth0 |
Adds a route. |
route del -net Destination subnet address netmask Destination subnet mask route del -net 10.224.0.0 netmask 10.240.0.0 |
Deletes a route. |
User Operations
SUSE Linux imposes strict rules on user management. Different users can access different applications.
Command |
Function |
---|---|
passwd |
Changes the password of a user. |
su - Operating system user name For example, to switch to the ossuser user, run the following command: su - ossuser NOTE:
The su-ossuser command is different from the su ossuser command.
|
Switches the operating system user. |
exit NOTE:
If you want to switch back to the root user, run the exit command multiple times until the prompt changes to #. |
Logs an operating system user out of the system. |
File Operations
Command |
Function |
---|---|
mkdir Directory name |
Creates a directory. |
rm -rf Directory |
Deletes a directory. |
rmdir Directory |
Deletes an empty directory. |
cd Directory name |
Switches to another directory. |
mv Source directory Destination directory |
Moves a directory or modifies the name of a directory. |
cp -r Source directory Destination directory |
Copies the directory. |
pwd |
Displays the current directory of the user. |
ls Option File directory |
Displays the directory content or file information. |
cd Absolute path/Relative path |
Accesses a specific directory. |
cd .. |
Switches to the high-level directory. |
cd - |
Accesses the directory that is accessed last time. |
vi File name |
Creates or modifies a text file. |
rm File name |
Deletes a file. |
cat File name |
Queries the file content. |
mv Source file Destination file path/Destination file name |
Moves a file or modifies the file name. |
cp Source file Destination file path |
Copies files. |
chown User name:Group name File name chown User name:Group name -R Directory name |
Changes the owner/owner group of a file/directory. |
chown XXX File name chown -R XXX Directory name NOTE:
In the command, XXX is a 3-digit octal number. |
Modifies the file/directory permission. |
find . -name "File name" NOTE:
The file name supports the wildcard (*). |
Searches for a file. |
grep "Search character" File name |
Searches for and displays the content in the line where the matching character is located. |
grep -n "Search character" File name |
Searches for and displays the line number of the matched content. |
grep -l "Search character" File name |
Searches for and displays the file name of the matched content. |
Compression and Decompression
Compression Format |
Command |
---|---|
.tar |
Compression: tar cvf Compression package name.tar Source directory/File Decompression: tar xvf Compression package name.tar |
.zip |
Compression: zip -r Compression package name.zip Source directory/File Decompression: unzip -d Decompression directory Compression package name.tar |
.tar.gz |
Decompression: tar zxvf Compression package name.tar.gz |
.gz |
Compression: gzip File name Decompression: gunzip Compression package name.gz |