Linux System administration commands

Source: Internet
Author: User
Tags system log

System and Management commands

Users and Groups class commands
Users
Degree of importance: Medium
Displays all logged-on users. This command is basically consistent with the who-q.

Groups
Degree of importance: Medium
Lists the current user and the group to which he belongs. This is equivalent to $GROUPS internal variables, but this command will give the group name, not the number.

Chown,chgrp
Degree of importance: high
The Chown command modifies the ownership of one or more files. This is a very good way for root to change the ownership of a file from one user to another. An ordinary user cannot modify the ownership of a file, even if he is the host of the file.
CHGRP will modify the ownership of a file or folder group. You must be the host of these files and be a member (or root) of the destination group in order to use this operation.

Useradd,userdel
Degree of importance: high
The Useradd Admin command will add a user account to the system and, if specified, create a home directory for a specific user. The corresponding Userdel command will remove a user account from the system and delete the corresponding file.
Note: The AddUser command is the same as Useradd, and adduser is usually a symbolic link.

Usermod
Degree of importance: high
Modify the user account. You can modify the password, group identity, due date, or other attributes for a given user account. Using this command, the user's password may be locked, because the password will affect the validity of the account.

Groupmod
Degree of importance: Medium
Modifies the specified group. The group name or ID number can be modified using this command.

Id
Degree of importance: high
The ID will list the actual and valid user IDs for the current process, as well as the user's group ID. This is with Bash's internal variables < Span class= "Mrow" id= "mathjax-span-2" > u i d , Euid and $GROUPS are very much alike.
NOTE: The ID command displays a valid ID only if the valid ID does not match the real ID.

W.H.O.
Degree of importance: Medium
Displays all users who are already logged on on the system.
The-M option will give you only the details of the current user. Passing any two parameters to who is equivalent to who-m, just like the Who am I or the Who-man.

W
Degree of importance: Medium
Displays all logged-in users and the processes that belong to them. This is an extended version of the WHO.

LogName
Degree of importance: Medium
Displays the login name of the current user (can be found in/var/run/utmp). This is very similar to the whoami above.
Note: LogName will only print out the logged-in user name, and WhoAmI will give the user name attached to the current process. As we see above, these two names are sometimes different.

Su
Degree of importance: high
Use a replacement user to run a program or script. Su Rjones will start a shell with Rjones. A non-parametric su default is root.

Sudo
Degree of importance: Medium
Run a command as root (or another user). This command can be run in the script, allowing the script to run as a regular user.

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

Ac
Importance level: Low
Displays the connection time of the user logon, as if it were read from/var/log/wtmp. This is a statistical tool for GNU.

Last
Degree of importance: Medium
The information that the user last logged in is like reading from/var/log/wtmp. This command can also be used to display remote logins.

Newgrp
Importance level: Low
You can modify the user's group ID without logging out and allow access to the new group's files. This command is rarely used because the user may belong to more than one group at a time.

Terminal class commands
Tty
Importance level: Low
Displays the name of the current user terminal. Note that each individual xterm window is counted as a different terminal.

Sty
Degree of importance: Medium
Display and/or modify terminal settings. This complex command can be used in scripts and can be used to control the behavior of the terminal and its way of displaying output. See the info page of this command and learn it carefully.

Tset
Importance level: Low
Displays or initializes terminal settings. It can be said that this is a weak version of the Stty function.

Setserial
Importance level: Low
Set or display the 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 level: Low
The initialization process for a terminal is usually established using Getty or Agetty, so that the user can log on. These commands are not used in the user's shell script. Their behavior is very similar to the stty.

Mesg
Importance level: Low
Enable or disable access to the current user terminal. Disabling access will prevent another user on the network from writing messages to this terminal.

Note: When you are writing a text file, there is a sudden and inexplicable message in the middle of the text, which is annoying to you. In a multi-user network environment, you might want to disable write access to your terminal when you don't want to be interrupted.

Wall
Importance level: Low
This is an abbreviated word "Write all", which means that a message is sent to all users who log on to any terminal on the network. Early this is an administrator's tool, useful, for example, when the system has a problem, management can warn everyone on the system to leave temporarily.

Uname
Degree of importance: high
Description of the output system (OS, kernel version, etc.) to stdout. With the-a option, detailed information will be given. Using the-s option will only output the OS type.

Arch
Degree of importance: Medium
Displays the hardware architecture of the system. Equivalent to Uname–m.

Lastcomm
Importance level: Low
Gives information about the previous command, stored in the/var/account/pacct file. Both the command name and the user name can be specified by using the option. This is a statistical tool for GNU.

Lastlog
Degree of importance: Medium
Lists the last logon time for all users on the system. exists in the/var/log/lastlog file.

Lsof
Degree of importance: high
Lists the open files. This command will list all currently open files with a detailed table, including the file owner information, size, information related to them, and so on.

Strace
Degree of importance: Medium
To track system and signal diagnostics and debugging tools. The simplest way to invoke it is to Strace COMMAND.
This is an equivalent tool for the Solaris Truss command Linux.

Nmap
Degree of importance: Medium
Network Port scanner. This command will scan a server to locate the open ports and locate the services associated with those ports. This is an important security tool to prevent the network from being hacked.

nc
Degree of importance: Medium
The NC (NETCAT) tool is a complete toolkit that you can use to connect and listen to TCP and UDP ports. It can be used as a diagnostic and test tool, or as a component of a script-based HTTP client and server.

Free
Degree of importance: high
Use tabular form to display memory and cache usage.

ProcInfo
Degree of importance: Medium
Extracts and displays all information and statistics from the/proc Pseudo-filesystem. This command will give you more detailed information.

Lsdev
Degree of importance: Medium
Display device, which is the display of the installed hardware.

Du
Degree of importance: high
The use status of recursive display (disk) files. Unless specified, the default is the current working directory.

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

Dmesg
Degree of importance: high
Output all system-initiated messages to stdout. Error-prone, and you can find out which devices are installed to drive and see which system interrupts are being used.

Stat
Degree of importance: high
Displays detailed statistics for one or more given files (which can also be catalog files or device files).

Vmstat
Degree of importance: high
Displays statistics about virtual memory.

Netstat
Degree of importance: high
Displays statistics and information for the current network, such as routing tables and active connections. This tool accesses the information in the/proc/net.
Netstat-r is equivalent to the route command.

Uptime
Degree of importance: high
Shows when the system is running, and some other statistics.

Hostname
Degree of 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). is equivalent to Uname-n and is similar to $hostname internal variables.

Hosted
Importance level: Low
Displays the 32-bit 16 binary ID of the host.

Sar
Degree of importance: high
The SAR (System activity Reporter Report) command will give a very detailed summary of the system statistics. Santa Cruz operation ("old" SCO) launched the SAR in April 1999 in the form of open source software. This command is not part of the basic Linux distribution, but you can get this tool from the Sysstat utilities package written by Sebastien Godard.

Readelf
Degree of importance: Medium
Displays statistics for 2 binaries in the specified elf format. This tool is part of the Binutils Toolkit.

Size
Degree of importance: Medium
The size [/path/to/binary] command displays the dimensions of each part of the 2 binary executable or archive file. This tool is primarily used by programmers.

System Log Class
Logger
Degree of importance: Medium
Attach a user-generated message to the system day (/var/log/messages). Not the root user can also call logger.

Logrotate
Degree of importance: high
This tool is used to manage the log files of the system and can be rotated, compressed, deleted and/or e-mail at the right time. This tool will get some messy records from the old log file saved in/var/log. Cron is typically used to run logrotate every day.
You can manage your own log files by adding the appropriate portals in the/etc/logrotate.conf, just like the management system
Log file.
Note: Stefano falsetto created Rottlog, which he thought was an improved version of Logrotate.

Job Control
Ps
Degree of importance: high
Process statistics: Lists the currently executing processes through the process owner and PID (process ID). This command is usually invoked using the AX option.

Pgrep, Pkill
Degree of importance: Medium
The PS command is used in conjunction with grep or kill.

Pstree
Degree of importance: high
Use the tree form to list the currently executing processes. The-P option displays the PID, and the process name.

Top
Degree of importance: high
Continuous display of processes with the highest CPU utilization. The-B option is displayed as text so that it can be parsed or accessed in the script.

Nice
Degree of importance: Medium
Use the modified priority to run a background job. The priority level is from 19 (lowest) to 20 (highest). Only the root user can set a negative (higher) priority. The related commands are renice,snice and skill.

Nohup
Degree of importance: high
Keep a command running even if the user is logged out of the system. This command is run as a foreground process unless you add & to the front.
If you use the Nohup command in a script, it is best to use the wait command, which avoids creating an orphan process or a zombie process.

Pidof
Degree of importance: Medium
Gets the process ID (PID) of a running job. Because some job control commands, such as kill and Renice, can only use the PID of the process (not its name), it is sometimes necessary to get the PID. The pidof command is very similar to $PPID internal variables.

Fuser
Degree of importance: Medium
Gets a process ID that is accessing one or some of the files (or directories). Using the-K option will kill these processes. This command is useful for system security, especially if you want to prevent unauthorized users from accessing system services in scripts.

Cron
Degree of importance: Medium
The hypervisor scheduler performs routine tasks such as purging and deleting system log files, or updating the database for the slocate command. This is the super User version of the AT command (although each user can have their own crontab file, and this file can be modified using the crontab command).

Process Control and Startup classes
Init
Degree of importance: high
The init command is the parent process for all processes. At the last step of the system startup, Init will determine the operating level of the system based on/etc/inittab. You can only run its alias Telinit by using the root identity.

Telinit
Degree of importance: high
A symbolic link to the init command, which is a means of modifying the operating level of the system, usually in the case of system maintenance or emergency file system repair. Can only be invoked using the root identity.

RunLevel
Degree of importance: Medium
Displays the current and final runlevel, which is to determine if your system is terminating (RunLevel is 0), running in single-user mode (1), multiuser mode (2), Running x Windows (5), or restarting (6). This command will access the/var/run/utmp file.

Halt, Shutdown, reboot
Degree of importance: high
The command to set the system shutdown is usually higher than the power shutdown priority.

Service
Degree of importance: high
Turn on 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 class
Ifconfig
Degree of importance: high
interface configuration and debugging tools for the network.

Iwconfig
Importance level: Low
This is a collection of commands to configure the wireless network. It can be said to be the wireless version of the top ifconfig.

Route
Degree of importance: high
Display the kernel routing table information, or view the changes to the kernel routing table.

Chkconfig
Degree of importance: high
Check the network configuration. This command is responsible for displaying and managing the network services that are opened during the boot process (these services are all from/ETC/RC?). Open in the D directory).

Tcpdump
Degree of importance: Medium
The "sniffer" of the network packet. This is a tool for analyzing and debugging the transmission on the network, and it uses the means to display the header that matches the specified rule.

File System Classes
Mount
Degree of importance: high
Loading a file system, typically used to install external devices, such as floppy disks or CDROM. File/etc/fstab will provide a handy list of all available file systems, partitions and devices, plus some options, such as whether you can automatically or manually mount. The file/etc/mtab shows the currently-mount file systems and partitions (including virtual, such as/proc).
Mount-a will mount all the file systems and partitions listed in the/ect/fstab, except those marked with non-automatic options. At boot time, a startup script in/etc/rc.d (rc.sysinit or some similar script) will be called so that all available file systems and partitions are on mount.

Umount
Degree of importance: high
Dismount a file system that is currently mount. This device must be unmount before the floppy disk and CDROM that have been mount before the normal deletion, or the file system will be corrupted.

Sync
Degree of importance: high
Force writes all data on the buffer that needs to be updated to the hard disk (synchronizing the drive with buffer). If it is not strictly necessary, a sync can ensure that the system administrator or the user just modified data will be safe in the sudden breakpoint to survive. Before the system restarts, the sync is used before the earlier one. Sync (two times to ensure absolute reliability), this is a very useful way to be careful.
Sometimes, such as when you want to safely delete a file, or when the disk light starts flashing, you may need to force a buffer refresh immediately.

Losetup
Degree of importance: Medium
Establish and configure loopback devices.

Mkswap
Degree of importance: Medium
Create a swap partition or file. The swap area must then be used immediately to enable swapon.

Swapon, Swapoff
Degree of importance: Medium
Enable/disable swapping of partitions or files. These two commands are usually valid at startup and shutdown.

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

Tune2fs
Degree of importance: high
Adjust the ext2 file system. Can be used to modify file system parameters, such as the maximum number of mount. Must be called as root.

Dumpe2fs
Degree of importance: Medium
Print (output to stdout) very detailed file system information. Must be called as root.

Hdparm
Degree of importance: Medium
Lists or modifies hard disk parameters. This command must be called as root, which can be dangerous if misused.

Fdisk
Degree of importance: high
Create and modify a partitioned table on a storage device (usually a hard disk). Must be used as root.

Fsck,e2fsck,debugfs
Degree of importance: high
File system check, fix, and debug command set.
FSCK: Check the UNIX file system's front-end tool (you can also call other tools). The type of file system is generally the default ext2.
E2fsck:ext2 File System checker.
DEBUGFS:EXT2 File System debugger. One of the uses of this versatile but dangerous tool is to (try) to recover deleted files. Only advanced users can use it.

System.
Badblocks
Importance level: Low
Check the storage device for bad blocks (physical corruption). This command is used when formatting a newly installed hard disk or when testing the integrity of a backup.

Lsusb,usbmodules
Importance level: Low
The LSUSB command lists all USB (Universal Serial bus Universal serial bus) buses and devices that use USB.
The usbmodules command outputs information about the driver module that connects the USB device.

Mkbootdisk
Importance level: Low
To create a boot diskette, the boot disk can wake up the system, such as when the MBR (Master boot record Master boot recording) is broken. The Mkbootdisk command is actually a Bash script, written by Erik Troan, and placed in the/sbin directory.

Chroot
Degree of importance: high
Modify the root directory. General commands are obtained from the $PATH, relative to the default root directory is/. This command will change the root directory to another directory (and will also modify the working directory to that). For security purposes, this command is useful, for example, when a system administrator wants to restrict certain users, such as Telnet, to a secure place on the filesystem (which is sometimes referred to as restricting a guest user to "Chroot prison"). Note that after using chroot, the directory of the system's binary executables will no longer be available.
Chroot/opt will make the original/usr/bin directory become/opt/usr/bin. Similarly, chroot/aaa/bbb/bin/ls will cause the LS command to be/aaa/bbb as the root directory, not the previous/. If you use alias xx ' chroot/aaa/bbb ls ' and put this sentence into the user's ~/.BASHRC file, this will be able to effectively limit the command "XX" when the command "XX" can use the scope of the file system.

Lockfile
Importance level: Low
This tool is part of the Procmail package (www.procmail.org). It can create a lock file, which is a tag file used to control access to files, devices, or resources. Locking a file is used just like a tag, if a particular file, device, or resource is being used by a particular process ("busy"), then for other processes it is restricted to access (or inaccessible).
Lock files are used in specific situations, such as protecting the system's mail directory to prevent multiple users from modifying at the same time, or prompting a modem port to be accessed, or showing an instance of Netscape using its cache. The script can do some checking work, such as a specific process can create a lock file, so long as the specific process to check whether it is running, you can determine whether the lock file exists. Note If the script tries to create a locked file that already exists, then the script is likely to be suspended.
In general, the app creates or checks that the locked files are placed in the/var/lock directory.

Mknod
Degree of importance: Medium
Create a block or character device file (which may be necessary when a new hard disk is installed on the system). The Makedev tool actually has the full functionality of Mknod and is easier to use.

Makedev
Degree of importance: Medium
Tools for creating device files. Must be in the/dev directory and be used as root.
This is the advanced version of Mknod.

Tmpwatch
Degree of importance: Medium
Automatically delete files that have not been accessed for a specified period of time. It is usually called by Cron to delete the old log file.

Backup class
Dump,restore
Importance level: Low
The dump command is an ingenious file system Backup tool that is typically used on larger installations and networks. It reads the original disk partition and writes a backup file in binary form. Files that need to be backed up can be saved on a variety of storage devices, including disks and tapes. The restore command is used to restore the backup generated by the dump.

Fdformat
Importance level: Low
Low-level format of the floppy disk.

System Resource Class
Ulimit
Degree of importance: high
Sets the upper limit for using system resources. It is usually called with the-f option, and-F is used to set the file size limit (ulimit-f 1000 is to limit the file size to 1M). -c option to limit the coredump size (ulimit-c 0 is not coredumps). In general, the value of Ulimit should be set in/etc/profile and/or ~/.bash_profile.

Quota
Degree of importance: Medium
Displays the disk quotas for the user or group.

Setquota
Degree of importance: Medium
Set the disk quotas for a user or group from the command line.

Umask
Degree of importance: high
Sets the default mask (mask) for permissions when a user creates a file. You can also use to restrict the default file attributes for a specific user. All user-created file attributes are specified by Umask.

Rdev
Degree of importance: Medium
Get information about the root device,swap space, or video mode, or modify it. Generally speaking, Rdev is used by Lilo, but this command is also useful when creating a RAM disk.

Module class
Lsmod
Degree of importance: Medium
Lists all installed kernel modules.

Insmod
Degree of importance: Medium
Force the installation of a kernel module (instead of using modprobe if possible) must be called as root.

Rmmod
Degree of importance: Medium
Forces the uninstallation of a kernel module. Must be called as root.

Modprobe
Degree of importance: Medium
The module loader, in general, is automatically called in the startup script. Must be called as root.

Depmod
Degree of importance: Medium
Create a module dependent file, which is typically called in a startup script.

Modinfo
Degree of importance: Medium
Outputs information for a loadable module.

Miscellaneous classes
Env
Degree of importance: Medium
Run a program or script with an environment variable that has been set up or modified (not the entire system environment). Use the [varname=xxx] form to modify environment variables in the script. If no parameters are specified, the command lists all environment variables that are set.

LDd
Degree of importance: Medium
Displays the dependencies of a shared library of an executable file.

Strip
Degree of importance: Medium
Remove the debug symbol reference from the executable file. This can reduce the size, but it cannot be debugged.

Nm
Degree of importance: Medium
Lists the symbols for the strip compiled 2 binaries.

Rdist
Degree of importance: Medium
Remote File Distribution client program: Synchronize, clone, or back up a file system on the remote server.

Linux System administration commands

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.