60 required commands for Linux [1] installation and login

Source: Internet
Author: User
Linux provides a large number of commands that can effectively perform a large amount of work, such as disk operations, file access, directory operations, process management, and file permission settings.

Linux provides a large number of commands that can be used to effectively complete a large amount of work, such as disk operations, file access, and object storage.
Operations, process management, and file permission settings. Therefore, working on a Linux system is inseparable from the mission provided by the system.
. To really understand the Linux system, you must learn from the Linux commands and further understand the Linux system through basic command learning.

The number of commands for different Linux distributions is different, but the minimum number of commands for Linux distributions is over 200. Here I
The following six sections describe commands that are important and frequently used in the system.

◆ Installation and logon commands: login, shutdown, halt, reboot, install, mount, umount, chsh,
Exit, last;

◆ File processing commands: file, mkdir, grep, dd, find, mv, ls, diff, cat, ln;

◆ System management commands: df, top, free, quota, at, lp, adduser, groupadd, kill,

◆ Network Operation Commands: ifconfig, ip, ping, netstat, telnet, ftp, route, rlogin, rcp,
Finger, mail, nslookup;

◆ System security related commands: passwd, su, umask, chgrp, chmod, chown, chattr, sudo ps,

◆ Other commands: tar, unzip, gunzip, unarj, mtools, man, unendcode, and uudecode.

This document uses Mandrake Linux 9.1 (Kenrel 2.4.21) as an example to introduce the installation and logon commands in Linux.


1. Role

Login is used to log on to the system and has the permission to all users.

2. Format

Login [name] [-p] [-h host name]
3. main parameters

-P: notifies login to retain the current environment parameters.

-H: used to transmit user names between remote logins.

If you choose to log on to Linux in command line mode, the first Linux command is login :.

The general interface is as follows:

Manddrake Linux release 9.1 (Bamboo) for i586
Kennel 2.4.21-0.13mdk on i686/tty1
Localhost login: root
In the above code, the first line is the Linux release version number, the second line is the kernel version number and the Virtual Console we log on.
Enter the login name in the third line, press Enter and Enter the account Password after the Password to log on to the system. Out of security
When you enter the account password, the characters are not displayed on the screen, and the cursor is not moved.

After logging on, you will see the following interface (taking the super user as an example ):

[Root @ localhost root] #
Last login: Tue, Nov 18 10:00:55 on vc/1
The preceding figure shows the logon day, month, day, and time, and the Virtual Console used.

4. application skills

Linux is a real multi-user operating system that allows multiple users to log on at the same time.
Logon times. This is because Linux, like many versions of Unix, provides access to the Virtual Console, allowing users
Log on to the console multiple times at the same time (the console of the system is a monitor and keyboard directly connected to the system. Each
Virtual consoles can be seen as an independent workstation and can be switched between workstations. You can switch between the Virtual Console and
By pressing the Alt key and a function key, a F1-F6 is usually used.

For example, after a user logs on, press the "Alt + F2" key to see the "login:" prompt above,
The user sees the second Virtual Console. Then press the "Alt + F1" key to return to the first virtual controller.
Platform. A newly installed Linux system allows users to access the first six virtual machines by pressing "Alt + F1" to "Alt + F6 ".
Console. What is most useful in the Virtual Console is that when a program error causes a system deadlock, you can switch to another virtual control
The system works and closes the program.


1. Role

The shutdown command is used to shut down the computer and its permission is a Super User.

2. Format

Shutdown [-h] [-I] [-k] [-m] [-t]
3. Important parameters

-T: Tell the init Program how long it will shut down before it changes to another running level.

-K: It does not actually shut down, but only sends a warning signal to each worker.

-H: power off after shutdown.

-C: cancel current process cancels the currently executing shutdown program. Therefore, this option certainly does not have time.
Parameter, but you can enter a message for explanation, and this information will be sent to each user.

-F: forces the fsck to restart the computer.

-Time: set the time before shutdown.

-M: change the system to single-user mode.

-I: The system information is displayed when the instance is shut down.

4. Command description

The shutdown command can safely shut down the system. Some users disable the Linux system by directly disconnecting the power supply.
This is very dangerous. Because Linux and Windows are different, many processes are running in the background, so force shutdown
It can cause data loss in the process, make the system unstable, and even damage the hardware in some systems (
Hard disk ). Use the shutdown command before shutting down the system. The system administrator will notify all logged-on users that the system will shut down.
And the login command is frozen, that is, new users cannot log on again.

5. example

Shutdown-h :40
Shutdown Starts.


1. Role

The role of the halt command is to shut down the system, and its permission is Super User.

2. Format

Halt [-n] [-w] [-d] [-f] [-I] [-p]
3. description of main parameters

-N: prevents sync system calls. it is used to fix the root partition with fsck to prevent kernel overwrites with the old version of Super block.
Overfix the super block.

-W: not a real restart or shutdown, but a wtmp (/var/log/wtmp) record.

-F: forced shutdown or restart without calling shutdown.

-I: shut down all network interfaces before shutting down (or restarting.

-F: Force shutdown without calling the shutdown command.

-P: when the power is turned off, the power is turned off by the way.

-D: shut down the system, but no record is left.

4. Command description

Halt is to call shutdown-h. When halt is executed, the application process is killed and sync is executed.
Mandatory write to hard disk) system call. after the file system write operation is completed, the kernel will be stopped. If the system running level is
0 or 6, the system is shut down; otherwise, it is replaced by the shutdown command (with The-h parameter.


1. Role

The reboot command is used to restart the computer. its permission is assigned to the system administrator.

2. Format

Reboot [-n] [-w] [-d] [-f] [-I]
3. main parameters

-N: Do not write the memory data back to the hard disk before restarting the instance.

-W: The record is not written to the/var/log/wtmp file.

-D: Do not write the record to the/var/log/wtmp file (the-n parameter contains-d ).

-I: stop all network-related devices before restarting.


1. Role

The install command is used to install or upgrade software or back up data. its permission is granted to all users.

2. Format

(1) install [options]… SOURCE Destination

(2) install [options]… Source... Directory

(3) install-d [option]… Directory...

In the first two formats <来源> Copy <目的地> Or multiple <来源> Copy the file to an existing <目录> ,
Set the permission mode and owner/group. In the third format, all specified directories and their master
Directory. Long options are required when short options are used.

3. main parameters

-- Backup [= CONTROL]: backs up each existing destination file.

-B: similar to -- backup, but does not accept any parameters.

-C: (this option is not processed ).

-D, -- directory: all parameters are processed as directories, and all directories in the specified directory are created.

-D: create <目的地> And then <来源> Copy <目的地> ; In the first format

-G, -- group = group: set the group to which the process belongs, rather than the current group to which the process belongs.

-M, -- mode = mode: Set the permission mode (such as chmod), instead of rwxr-xr-x.

-O, -- owner = owner: Set the owner (applies to super users only ).

-P, -- preserve-timestamps: <来源> File Access/modification time as the corresponding destination file
Time attribute.

-S, -- strip: Use the strip command to delete the symbol table, only applicable to the first and second formats.

-S, -- suffix = suffix: specifies the backup file's <后缀> .

-V, -- verbose: The name is printed when processing each file/directory.

-- Help: displays the help information and leaves.

-- Version: displays the version information and leaves.


1. Role

The mount command is used to load the file system. its permission is granted to a super user or a user allowed in/etc/fstab.

2. Format

Mount-a [-fv] [-t vfstype] [-n] [-rw] [-F] device dir
3. main parameters

-H: displays the auxiliary information.

-V: display information, usually used with-f for debugging.

-A: Mount all file systems defined in/etc/fstab.

-F: this command is usually used with-a, which generates a route for each mount action. In
The system needs to mount a large number of NFS file systems to speed up loading.

-F: usually used for debugging. It will make the mount not execute the actual hanging action, but simulate the entire hanging process, usually
It will be used with-v.

-T vfstype: displays the type of the file system to be loaded.

-N: generally, after mount is mounted, a piece of data is written to the/etc/mtab. no file system can be written to the system.
You can use this option to cancel this operation.

4. application skills

On Linux and Unix systems, all files are accessed as part of a large tree (with/as the root. To access
The file on the CD-ROM, which needs to mount the CD-ROM device to a mount point in the file tree. If the release version is installed automatically
Install the package automatically. In Linux, if you want to use hard drives, optical drives, and other storage devices, you have
Load it first. after the storage device is mounted, it can be accessed as a directory. Use a device
Mount command. When using the mount command, you must first know at least three types of information: the file system of the object to be loaded
Type, the device name of the object to be loaded, and the Directory to which the device is loaded.

(1) recognizable file systems in Linux

◆ Windows 95/98 common FAT 32 file system: vfat;

◆ Win NT/2000 File System: ntfs;

◆ OS/2 file system: hpfs;

◆ Linux File Systems: ext2 and ext3;

◆ CD-ROM Disc File System: iso9660.

Although vfat is a FAT 32 system, it is actually compatible with the file system type of FAT 16.

(2) determine the device name

In Linux, device names are usually stored in/dev. The names of these devices are named in a regular manner.
To find the device name. For example, the/dev/hda1 IDE device, hd is Hard Disk,
Sd is a SCSI Device, fd is a Floppy Device (or Floppy Disk ?). A represents the first device, usually connected by the IDE
You can connect four IDE devices (such as four hard disks ). Therefore, the methods to identify IDE hard disks are hda, hdb, and hdc.
And hdd. In hda1, "1" indicates the first hard disk partition of hda. hda2 indicates the second primary partition of hda.
Partition, the first logical partition starts from hda5, and so on. In addition, you can directly check the/var/log/messages file
In this file, you can find the device code identified by the system after the computer is started.

(3) Find the mount point

Before deciding to connect the device, check whether the computer has an empty/mnt directory.
As the Mount Point directory. We recommend that you create several/mnt/cdrom,/mnt/floppy,
/Mnt/mo and other directories as dedicated Mount points of the Directory. For example, to mount the following five devices, the command can be executed:
Can be as follows (assuming all are Linux ext2 systems, if it is Windows XX, change ext2 to vfat ):

Floppy disk ==> mount-t ext2/dev/fd0/mnt/floppy
Cdrom ==> mount-t iso9660/dev/hdc/mnt/cdrom
SCSI cdrom ==> mount-t iso9660/dev/sdb/mnt/content ROM
SCSI cdr ==> mount-t iso9660/dev/sdc/mnt/scdr
However, most of the latest Linux releases (including Hongqi Linux, zhongsoft Linux, and Mandrake Linux)
You can automatically mount the file system, except for Red Hat Linux.


1. Role

The umount command is used to uninstall a file system. its permission is allowed by a super user or by/etc/fstab.

2. Format

Umount-a [-fFnrsvw] [-t vfstype] [-n] [-rw] [-F] device dir
3. Instructions for use

The umount command is the inverse operation of the mount command. its parameters and usage are the same as those of the mount command. Linux mounting
After the CD-ROM, the CD-ROM is locked so that it cannot be popped up with the Eject button on the CD-ROM panel. However
If you have used/cdrom as a symbolic link when you need a CD, use umount/cdrom to uninstall it. Only when the user is useless
This command is successful only when you use the CD. This command includes
Terminal window.


1. Role

The chsh command is used to change the user shell settings, and its permission is for all users.

2. Format

Chsh [-s] [-list] [-- help] [-v] [username]
3. main parameters

-L: displays all Shell types of the system.

-V: displays the Shell version number.

4. application skills

We have introduced a variety of shells in Linux. the default is Bash. if you want to change the Shell type, you can use chsh.
Command. First, enter the account password, and then enter the new Shell type. if the operation is correct, the system displays "Shell change
". The interface is generally as follows:

Changing fihanging shell for cao
New shell [/bin/bash]:/bin/tcsh
In the above code, the current Shell is used in. Normal users can only modify their own shells, and super users can repair
Change the Shell of all users. To query which shells are provided, run the chsh-l command, as shown in.


Shell types that can be used by the system


We can see that the Shell in the system can be used in bash (default), csh, sh, and tcsh.


1. Role

The exit command exits the system and has the permission to all users.

2. Format


3. parameters

The exit command has no parameters. after running the command, exit the system and enter the logon interface.


1. Role

The last command is used to display the logon status of recent users or terminals. its permission is granted to all users. Pass the last life
To view the log of the program, the administrator can know who has or attempted to connect to the system.

2. Format

1ast [-n] [-f file] [-t tty] [-h node] [-I-IP] [-1] [-y] [1D]
3. main parameters

-N: number of output records.

-F file: specifies that the file is used as the log file for query.

-T tty: only the logon status on the specified Virtual Console is displayed.

-H node: only the logon status on the specified node is displayed.

-I IP: only the logon status on the specified IP address is displayed.

-1: use an IP address to display the remote address.

-Y: displays the year, month, and day of the record.

-ID: the user name to be queried.

-X: displays the system shutdown, user logon, and logout history.

Hands-on exercises

The above describes the Linux installation and logon commands. The following describes several instances and describes how to practice the commands just mentioned.

1. run multiple commands at a time

You can execute multiple commands in one command line and separate them with semicolons. for example:

# Last-x; halt
The code above indicates that the computer is disabled after the system is disabled, user logon, and logout history are displayed.

2. use mount mounted file system to access Windows

Many Linux versions can now automatically load Vfat partitions to access Windows systems, while Red Hat versions
Vfat partitions are not automatically loaded, so manual operations are required.

Mount can be used to mount a Windows partition as a "file" of Linux to an empty folder in Linux.
The Windows partition is associated with the/mnt directory. Therefore, accessing this folder is equivalent to accessing this partition.
. First, create a winc folder under/mnt and enter the following command at the command prompt:

# Mount-t vfat/dev/hda1/mnt/winc
That is, the Windows C partition is mounted to the/mnt/winc directory of Liunx. In this case, in the/mnt/winc directory, you can
The content of drive C in Windows is displayed. You can use a similar method to access D and E disks in Windows. In Linux
Display the Windows partition in the following general order: hda1 is drive C, hda5 is drive D, hda6 is drive e ...... And so on.
The above method shows that there is a big problem in Windows, that is, all Chinese file names or files in Windows.
All folder names are displayed as question marks "?", English is displayed normally. We can add some parameters to make it explicit
Display Chinese characters. For example, enter the following command:

# Mount-t vfat-o iocharset = cp936/dev/hda1/mnt/winc
Now it can display Chinese characters normally.

3. mount the file system on the flash disk with mount

Using flash disks in Linux is very simple. Linux has good support for USB devices. when a flash disk is inserted, the flash disk is identified.
For a SCSI disk, enter the following command:

# Mount/dev/sda1/usb
You can mount the file system on the flash disk.


Linux commands and Shell

Shell is a command-interpreted program. It provides an interface for programming. Learning
Shell is very important for Linux beginners to understand the Linux system. Linux Shell is used as an external operating system
Shell, providing users with an interface to use the operating system. Shell is a command language, command interpreter program, and programming language.
Is the interface program between the user and the Linux kernel. If you think of the Linux kernel as the center of a sphere,
Shell is the outer layer around the kernel. When commands are passed from Shell or other programs to Linux, the kernel will make the corresponding
Response. Role of Shell in Linux and COMMAND. COM in ms dos and COMMAND. COM in Windows 95/98
Assumer.exe is similar. Although Shell is not a part of the system's core, it is only an extension of the system's core, but it can
It is enough to call most of the functions of the system kernel. Therefore, Shell is the most important utility in Unux/Linux.

There are multiple types of Shell in Linux, among which the most commonly used are Bourne Shell (sh), C Shell (csh), and Korn
Shell (ksh ). The default Shell of most Linux releases is Bourne Again Shell, which is Bourne.
Shell Extension, bash for short, is fully backward compatible with the Bourne Shell, and is added based on the Bourne Shell
Added many features. Bash is placed in/bin/bash, which provides functions such as command completion, command editing, and command history table.
Yes. It also contains many advantages of C Shell and Korn Shell, flexible and powerful programming interfaces, and
Friendly user interface. In Linux, 40 of the more than 200 commands are bash internal commands, mainly including exit
, Less, lp, kill, cd, pwd, fc, fg, etc.

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.