Linux system management commands and linux System Management

Source: Internet
Author: User

Linux system management commands and linux System Management

System and management commands

Users and Groups commands
Users
Importance: Medium
Displays all logged-on users. This command is basically the same as who-q.

Groups
Importance: Medium
Lists the current user and the group it belongs. This is equivalent to $ GROUPS internal variable, but this command will give the group name, not a number.

Chown, chgrp
Importance: high
The chown command modifies the ownership of one or more files. For root, this is a very good way to change the ownership of a file from one user to another. A common user cannot modify the ownership of a file, even if it is the file host.
Chgrp modifies the ownership of a file or folder group. You must be the host of these files and be a member of the target group (or root) to use this operation.

Useradd, userdel
Importance: high
The useradd management command adds a user account to the system, and if specified, creates a home directory for a specific user. The corresponding userdel command will delete a user account from the system and delete the corresponding files.
Note: The adduser command is the same as useradd. adduser is usually a symbolic link.

Usermod
Importance: high
Modify a user account. You can change passwords, group identities, end dates, or other attributes of a given user account. With this command, the user's password may be locked because the password will affect the account validity.

Groupmod
Importance: Medium
Modify the specified group. You can use this command to modify the group name or ID.

Id
Importance: high
Id will list the real and valid user IDs of the current process, as well as the user group ID. This is consistent with the Bash internal variable. UID, EUID is very similar to $ GROUPS.
Note: The id command displays a valid ID only when the valid ID does not match the real id.

Who
Importance: Medium
Displays all logged-on users on the system.
-The m option will only show the details of the current user. Passing any two parameters to who is equivalent to who-m, just like who am I or who The Man.

W
Importance: Medium
Displays all logged-on users and their processes. This is an extension of who.

Logname
Importance: Medium
Display the login name of the current user (which can be found in/var/run/utmp ). This is very similar to the above whoami.
Note: logname only prints the logon user name, while whoami gives the user name that is attached to the current process. As we can see above, these two names are sometimes different.

Su
Importance: high
Use an alternative user to run a program or script. Su rjones starts a shell with rjones. Root is the default su without parameters.

Sudo
Importance: Medium
Run a command as root (or another user. This command can be run in the script so that the script can be run as a regular user.

Passwd
Importance: high
Set, modify, or manage user passwords.
The-l,-u, and-d options of the passwd command allow locking, unlocking, and deleting a user's password. Only root users can use these options.

Ac
Importance: low
Display the connection time of user logon, just as reading from/var/log/wtmp. This is a GNU statistical tool.

Last
Importance: Medium
The user's final logon information is the same as reading from/var/log/wtmp. This command can also be used to display remote logon.

Newgrp
Importance: low
You can modify the user's group ID without logging out and allow access to files in the new group. Because the user may belong to multiple groups at the same time, this command is rarely used.

Logging commands
Tty
Importance: low
Displays the name of the current user terminal. Note that each xterm window is counted as a different terminal.

Sty
Importance: Medium
Display and (or) Modify terminal settings. This complex command can be used in scripts and used to control terminal behavior and display output methods. Refer to the info page of this command and learn it carefully.

Tset
Importance: low
Display or initialize terminal settings. It can be said that this is a weak version of stty.

Setserial
Importance: low
Set or display serial port parameters. This script can only be run by the root user and is usually used in the system installation script.

Getty, agetty
Importance: low
The initialization process of a terminal is usually established using getty or agetty, so that users can log on. These commands are not used in your shell script. They behave like stty.

Mesg
Importance: low
Enable or disable the access permissions of the current user terminal. Disabling the access permission will prevent another user from writing messages to this terminal.

Note: when you are writing a text file, a strange message suddenly comes in the middle of the text, which is very annoying for you. In a multi-user network environment, if you do not want to be interrupted, you may wish to disable write permissions on your terminal.

Wall
Importance: low
This is an abbreviation of "write all", that is, to send a message to all users logged on to any terminal on the network. This is an administrator tool at the earliest and is very useful. For example, when the system is faulty, the administrator can warn everyone on the system to leave temporarily.

Uname
Importance: high
Output System Description (OS, kernel version, and so on) to stdout. Use the-a option to provide detailed information. The-s option only outputs the OS type.

Arch
Importance: Medium
Displays the hardware architecture of the system. It is equivalent to uname-m.

Lastcomm
Importance: low
The information of the previous command is stored in the/var/account/pacct file. You can use the options to specify both the command name and user name. This is a GNU statistical tool.

Lastlog
Importance: Medium
Lists the last logon times of all users on the system. It exists in the/var/log/lastlog file.

Lsof
Importance: high
List open files. This command will list all open files in a detailed table, including the file owner information, size, and information related to them.

Strace
Importance: Medium
Diagnostic and debugging tools for tracking systems and signals. The simplest way to call it is strace COMMAND.
This is an equivalent tool for Linux with the Solaris truss command.

Nmap
Importance: Medium
Network port scanner. This command will scan a server to locate opened ports and services related to these ports. This is an important security tool to prevent network intrusion.

Nc
Importance: Medium
The nc (netcat) tool is a complete toolkit that can be used to connect to and listen to TCP and UDP ports. It can be used as a diagnostic and testing tool, or as a script-based HTTP client and server component.

Free
Importance: high
Use tables to Display memory and cache usage.

Procinfo
Importance: Medium
Extract and display all information and statistics from/proc pseudo-filesystem. This command provides more detailed information.

Lsdev
Importance: Medium
Displays the device, that is, the installed hardware.

Du
Importance: high
Recursively display the usage of (Disk) files. Unless specified, the current working directory is used by default.

Df
Importance: high
Displays the usage of the file system in the form of a list.

Dmesg
Importance: high
Output all system startup messages to stdout. Errors are easy, and you can find out which device drivers are installed and which system interruptions are used.

Stat
Importance: high
Displays detailed statistics of one or more given files (or directory files or device files.

Vmstat
Importance: high
Displays the statistics of virtual memory.

Netstat
Importance: high
Displays statistics and information about the current network, such as the route table and the activated connection. This tool accesses information in/proc/net.
Netstat-r is equivalent to the route command.

Uptime
Importance: high
Displays the system running time and other statistics.

Hostname
Importance: high
Displays the Host Name of the system. This command sets the host name in the/etc/rc. d installation script (/etc/rc. d/rc. sysinit or similar. It is equivalent to uname-n and is very similar to the $ HOSTNAME internal variable.

Hosted
Importance: low
Displays the 32-bit hexadecimal ID of the host.

Sar
Importance: high
The sar (System Activity Reporter System Activity Report) command provides a very detailed summary of System statistics. Santa Cruz Operation ("old" SCO) released sar in October in the form of open-source software. This command is not part of the basic Linux release, but you can get this tool from the sysstat utilities package written by Sebastien Godard.

Readelf
Importance: Medium
Displays the statistics of a binary file in the specified elf format. This tool is part of the binutils toolkit.

Size
Importance: Medium
The size [/path/to/binary] command displays the size of each part of a binary executable or archive file. This tool is mainly used by programmers.

System Logs
Logger
Importance: Medium
Attaches a user-generated message to the system day (/var/log/messages ). You can also call logger if it is not a root user.

Logrotate
Importance: high
This tool is used to manage system log files. It can rotate, compress, delete, and (or) E-mail them when appropriate. This tool saves some messy records from the old log files in/var/log. Generally, cron is used to run logrotate every day.
Add an appropriate entry to/etc/logrotate. conf to manage your own log files, just like the Management System
Log files are the same.
Note: Stefano Falsetto creates a rottlog, which he thinks is an improved version of logrotate.

Job Control
Ps
Importance: high
Process statistics: lists the processes currently executed by the process owner and PID (process ID. This command is usually called using the ax option.

Pgrep, pkill
Importance: Medium
The ps command is used in combination with grep or kill.

Pstree
Importance: high
Use the tree to list the currently executed processes. The-p option displays the PID and process name.

Top
Importance: high
Continuously displays the processes with the highest cpu usage. -Option B is displayed in text for analysis or access in scripts.

Nice
Importance: Medium
Use the modified priority to run a background job. The priority ranges from 19 (lowest) to-20 (highest ). Only root users can set a negative (relatively high) priority. Related commands are renice, snice, and skill.

Nohup
Importance: high
Keep a command running, even if the user logs out of the system. This command is run as a front-end process, unless the front side adds &.
If you use the nohup command in the script, you 'd better use it with the wait command to avoid creating an orphan or zombie process.

Pidof
Importance: Medium
Obtain the PID of a running job ). Some job control commands, such as kill and renice, can only use the process PID (rather than its name), so sometimes the PID must be obtained. The pidof command is very similar to the $ PPID internal variable.

Fuser
Importance: Medium
Gets the ID of a process that is accessing one or more files (or directories. Using the-k option will kill these processes. This command is useful for system security, especially when the script is used to prevent unauthorized users from accessing system services.

Cron
Importance: Medium
Manage the Program Scheduler and execute some daily tasks, such as clearing and deleting system log files or updating the database of the slocate command. This is the Super User version of the at command (although each user can have its own crontab file, and this file can be modified using the crontab command ).

Process Control and startup
Init
Importance: high
The init command is the parent process of all processes. In the last step of system startup, init will determine the system running level based on/etc/inittab. Only the root identity can be used to run its alias telinit.

Telinit
Importance: high
The symbolic link of the init command, which is a means of modifying the system running level. It is usually used during system maintenance or urgent file system repair. It can only be called as root.

Runlevel
Importance: Medium
Display the current and last running levels, that is, determine whether your system is terminated (runlevel is 0), whether it is running in single-user mode (1), multi-user mode (2 ), or running on X Windows (5) or restarting (6 ). This command will access the/var/run/utmp file.

Halt, shutdown, reboot
Importance: high
The command for setting the system to shut down usually has a higher priority than that for power shutdown.

Service
Importance: high
Enable or stop a system service. The STARTUP script is in/etc/init. d, and/etc/rc. d uses this command to start the service when the system starts.

Network Type
Ifconfig
Importance: high
Network Interface Configuration and debugging tools.

Iwconfig
Importance: low
This is a command set for configuring wireless networks. The above is the wireless version of ifconfig.

Route
Importance: high
Display the kernel route table information or view the modifications to the kernel route table.

Chkconfig
Importance: high
Check the network configuration. This command is used to display and manage the network services enabled during the startup process (these services are from/etc/rc ?. D directory ).

Tcpdump
Importance: Medium
Network Package "sniffer ". This is a tool used to analyze and debug the Transmission Conditions on the network. It is used to display the headers matching the specified rules.

File System
Mount
Importance: high
A file system is usually used to install external devices, such as a floppy disk or CDROM. File/etc/fstab provides a convenient list of all available file systems, partitions, and devices. In addition, it includes some options, for example, whether automatic or manual mount is allowed. The file/etc/mtab displays the mounted file systems and partitions (including virtual, such as/proc ).
Mount-a will mount all file systems and partitions in/ect/fstab, except those marked with non-automatic options. At startup, a STARTUP script (rc. sysinit or similar script) in/etc/rc. d will call this method to mount all available file systems and partitions.

Umount
Importance: high
Detaches a mounted file system. This device must be unmounted before the mounted floppy disk and CDROM are deleted. Otherwise, the file system will be damaged.

Sync
Importance: high
Force write all data on the buffer to be updated to the hard disk (with a buffer drive ). If not strictly necessary, one sync ensures that the data that the system administrator or user just modified will survive the sudden breakpoint safely. Previously, sync and sync were used before the system was restarted (twice, which ensures absolute reliability). This is a useful and careful method.
Sometimes, for example, when you want to safely delete a file, or when the disk light starts to flash, you may need to force the buffer to refresh immediately.

Losetup
Importance: Medium
Create and configure a loopback device.

Mkswap
Importance: Medium
Create a swap partition or file. You must use swapon immediately to enable the swap area.

Swapon, swapoff
Importance: Medium
Enable/disable swap partition or file. These two commands are generally effective at startup and shutdown.

Mke2fs
Importance: high
Create a Linux ext2 file system. This command must be called as root.

Tune2fs
Importance: high
Adjust the ext2 file system. It can be used to modify file system parameters, such as the maximum number of mounts. Must be called as root.

Dumpe2fs
Importance: Medium
Print (output to stdout) detailed file system information. Must be called as root.

Hdparm
Importance: Medium
List or modify hard disk parameters. This command must be called as root, which is dangerous if abused.

Fdisk
Importance: high
Create and modify a partition table on a storage device (usually a hard disk. Must be used as root.

Fsck, e2fsck, debugfs
Importance: high
File System check, repair, and debugging command set.
Fsck: checks the front-end tools of UNIX file systems (other tools can also be called ). The file system type is usually ext2 by default.
E2fsck: ext2 File System checker.
Debugfs: ext2 file system debugger. One of the usefulness of this versatile but dangerous tool is to (attempt) Restore deleted files. Only advanced users are available.

System.
Badblocks
Importance: low
Check the bad block of the storage device (physically damaged ). This command is used when formatting the newly installed hard disk or testing the integrity of the backup.

Lsusb and USB modules
Importance: low
The lsusb command lists all USB (Universal Serial Bus) buses and devices that use USB.
The usbmodules command outputs the information of the driver module connecting to the USB device.

Mkbootdisk
Importance: low
When a boot floppy disk is created, the boot disk can wake up the system, for example, when the MBR (master boot record) breaks down. The mkbootdisk command is actually a Bash script written by Erik Troan and stored in the/sbin directory.

Chroot
Importance: high
Modify the ROOT directory. The Common commands are obtained from $ PATH. The default root directory is /. This command will change the root directory to another directory (and also change the working directory to that ). For security purposes, this command is very useful. For example, when the system administrator wants to restrict some specific users, such as telnet users, restrict them to a safe place on the file system (this is sometimes called limiting a guest user to "chroot ). Note: After chroot is used, the system's binary executable file directory will no longer be available.
Chroot/opt will change the original/usr/bin directory to/opt/usr/bin. Similarly, chroot/aaa/bbb/bin/ls will make the ls command use/aaa/bbb as the root directory, instead of the previous /. If you use alias XX 'chroot/aaa/bbb ls' and place this sentence in the user's ~ In the/. bashrc file, this can effectively limit the range of file systems that can be used when the command "XX" is run and the command "XX" is run.

Lockfile
Importance: low
This tool is part of the procmail package (www.procmail.org ). It can create a locked file. A locked file is a Tag file used to control access to files, devices, or resources. A locked file is used just like a tag. If a specific file, device, or resource is being used by a specific process ("busy"), for other processes, access is restricted (or not accessible ).
Locking a file is used in some special scenarios, such as protecting the system's mail directory to prevent multiple users from simultaneously modifying the file, or prompting that a modem port is being accessed, or an instance of Netscape is using its cache. The script can perform some checks. For example, if a specific process can create a locked file, you only need to check whether the specific process is running and whether the locked file exists. Note: If the script tries to create an existing locked file, the script may be suspended.
Generally, the application creation or check for locked files are stored in the/var/lock directory.

Mknod
Importance: Medium
Create block or character device files (which may be necessary when a new hard disk is installed on the system ). MAKEDEV actually has all the functions of mknod and is easier to use.

MAKEDEV
Importance: Medium
A tool used to create a device file. It must be in the/dev directory and used as root.
This is an advanced version of mknod.

Tmpwatch
Importance: Medium
Automatically delete files that have not been accessed within the specified time. It is usually called by cron to delete old log files.

Backup class
Dump, restore
Importance: low
The dump command is a sophisticated file system backup tool, which is usually used for large installations and networks. It reads original disk partitions and writes backup files in binary format. Files to be backed up can be stored on a variety of storage devices, including disks and tapes. The restore command is used to restore the backup generated by dump.

Fdformat
Importance: low
Low-level formatting of a floppy disk.

System Resources
Ulimit
Importance: high
Set the upper limit for using system resources. Generally, the-f option is used for calling.-f is used to set the file size limit (ulimit-f 1000 is to limit the file size to 1 MB ). -C option to limit the coredump size (ulimit-c 0 means not coredumps ). Generally, the ulimit value should be set in/etc/profile and (or )~ /. Bash_profile.

Quota
Importance: Medium
Displays the disk quota of a user or group.

Setquota
Importance: Medium
Set the disk quota for the user or group from the command line.

Umask
Importance: high
Sets the default mask (mask) for permissions when users create files ). It can also be used to restrict the default file attributes of a specific user. All file attributes created by users are specified by umask.

Rdev
Importance: Medium
Obtain information about the root device, swap space, or video mode, or modify them. Generally, rdev is used by lilo, but this command is also useful when creating a ram disk.

Module type
Lsmod
Importance: Medium
List all installed kernel modules.

Insmod
Importance: Medium
Force the installation of a kernel module (if possible, use modprobe) must be called as root.

Rmmod
Importance: Medium
Force Uninstall a kernel module. Must be called as root.

Modprobe
Importance: Medium
The module loader is generally automatically called in the startup script. Must be called as root.

Depmod
Importance: Medium
Create a module dependency file, which is generally called in the startup script.

Modinfo
Importance: Medium
Output Information of A loadable module.

Miscellaneous
Env
Importance: Medium
Run a program or script using the set or modified environment variables (not the entire system environment. You can modify the environment variables in the script in the form of [varname = xxx. If no parameter is specified, this command will list all the set environment variables.

Ldd
Importance: Medium
Displays the dependency of an executable file's shared library.

Strip
Importance: Medium
Remove the debugging symbol reference from the executable file. This can reduce the size, but debugging is not available.

Nm
Importance: Medium
List the symbols of compiled binary files that have not been strip.

Rdist
Importance: Medium
Remote File distribution client program: Synchronize, clone, or back up a file system on a remote server.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.