Viewing the IP address ifconfig is equivalent to ipconfig in the window.
Remote logon command rdesktop-f-a 16 192.168.10.10
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. Therefore, operating on a Linux system requires the use of commands provided by the system. To really understand the Linux system, you must start with the Linux Command and learn the basic command to further understand the Linux system.
The number of commands for different Linux distributions is different, but the minimum number of commands for Linux distributions is over 200. Here I will introduce the most important and frequently used commands in the following six parts according to their functions in the system.
◆ Installation and logon commands: login, shutdown, halt, reboot, install, mount, umount, chsh, exit, and 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, and crontab;
◆ Network operation commands: ifconfig, ip, ping, netstat, telnet, ftp, route, rlogin, rcp, finger, mail, and nslookup;
◆ System security related commands: passwd, su, umask, chgrp, chmod, chown, chattr, sudo ps, who;
◆ 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.
Login
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
Renrel 2.4.21-0.13mdk on i686/tty1
Localhost login: root
Password:
In the code above, the first line is the Linux release version number, the second line is the kernel version number and the virtual console we log on to. In the third line, we enter the login name, press Enter and Enter the account Password to log on to the system. For security reasons, the characters are not displayed on the screen when the account password is entered, 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 simultaneously and allows one user to log on multiple times. This is because Linux, like many versions of UNIX, provides access to the virtual console, allowing users to access the console at the same time (the system console is a monitor and keyboard directly connected to the system) log on multiple times. Each virtual console can be seen as an independent workstation, and can be switched between workstations. The switchover of the virtual console can be done by pressing the Alt key and a function key, typically using a F1-F6.
For example, after a user logs on, press the "Alt + F2" key and the user will see the "login:" prompt above, indicating that the user has seen the second virtual console. Then, press the "Alt + F1" key to return to the first virtual console. A newly installed Linux system allows you to use the Alt + F1 key to access the first six virtual consoles. The most useful thing about the virtual console is that when a program error causes a system deadlock, you can switch to another virtual console to close the program.
Shutdown
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 a 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. It is very dangerous for some users to shut down the Linux system by directly disconnecting the power supply. Because Linux and Windows run many processes in the background, forced shutdown may lead to data loss in the process and make the system unstable, in some systems, hardware devices (hard disks) are damaged ). 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 will be frozen, that is, new users cannot log on again.
Halt
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 the sync system from calling. It is used after the root partition is repaired with fsck to prevent the kernel from overwriting the repaired super block with the old version.
-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 the system call is executed by executing sync (forcibly writing data stored in the buffer to the hard disk). After the file system write operation is completed, the kernel is stopped. If the system running level is 0 or 6, the system is shut down; otherwise, the shutdown command (with the-h Parameter added) is replaced.
Reboot
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.
Install
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, <source> copy to <destination> or copy multiple <source> files to an existing <directory>, set the permission control mode and owner/group. In the third format, all specified directories and their home directories are created. 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 all the Home Directories Before <destination> and copy <source> to <destination>. It is useful 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: Use the <source> File Access/modification time as the time attribute of the corresponding destination file.
-S, -- strip: Use the strip command to delete the symbol table, only applicable to the first and second formats.
-S, -- suffix = suffix: Specifies the <suffix> of the backup file.
-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.
Mount
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. It can speed up loading when the system needs to mount a large number of NFS file systems.
-F: usually used for debugging. It causes mount to not execute the actual mounting action, but simulate the entire mounting process, which is usually used together with-v.
-T vfstype: displays the type of the file system to be loaded.
-N: In general, after mount is mounted, a piece of data will be written to the/etc/mtab. You can use this option to cancel this operation if the system does not have the file system to write data.
4. Application Skills
On Linux and Unix systems, all files are accessed as part of a large tree (with/as the root. To access files on the CD-ROM, You need to mount the CD-ROM device to a mount point in the file tree. If the release version is installed with an automatic mounting package, this step can be performed automatically. In Linux, if you want to use storage devices such as hard disks and optical drives, you must load them first. When the storage device is mounted, you can use it as a directory for access. Mount a device and run the mount command. When using the mount command, you must first know the following three types of information: file system type of the object to be loaded, device name of the object to be loaded, and directory to which the device is to be 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. These device names are named in a regular way. You can use the "inference" method to find the device names. For example, the/dev/hda1 IDE Device, hd is Hard Disk, sd is SCSI Device, fd is Floppy Device (or Floppy Disk ?). A Indicates the first device. Generally, the IDE interface can be connected to four IDE devices (such as four hard disks ). Therefore, the methods to identify IDE Hard Disks are hda, hdb, hdc, and hdd. In hda1, "1" indicates the first hard disk partition of hda, hda2 indicates the second primary partition of hda, and the first logical partition starts from hda5. In addition, you can directly check the/var/log/messages file to 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, which is used as a Mount Point directory. We recommend that you create several/mnt/cdrom,/mnt/floppy,/mnt/mo directories in/mnt as dedicated mount points for the directories. For example, if you want to mount the following five devices, the execution command may be as follows (assuming that all are Linux ext2 systems, and 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 Red Flag Linux, mid-soft Linux, and Mandrake Linux) can automatically mount the file system, except Red Hat Linux.
Umount
1. Role
The umount command is used to uninstall a file system. Its permission is granted to a Super User or a user allowed in/etc/fstab.
2. Format
Unmount-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. After the Linux mounted 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 no longer need a CD, use umount/CDROM to uninstall it if you have used/CDROM as a symbolic link. This command is successful only when no user is using the CD. This command includes a terminal window that uses the current working directory as the directory in the CD.
CHSH
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. To change the shell type, you can use the CHSH command. Enter the account password and the new shell type. If the operation is correct, "shell change" is displayed ". The interface is generally as follows:
Changing fihanging shell for Cao
Password:
New shell [/bin/bash]:/bin/tcsh
In the above Code, the current Shell is used in. Normal users can only modify their own shells. Super Users can modify the shells of all users. To query which shells are provided, run the chsh-l command, as shown in figure 1.
Figure 1 Shell types available for the System
As shown in figure 1, the Shell that can be used in my system includes bash (default), csh, sh, and tcsh.
Exit
1. Role
The exit command exits the system and has the permission to all users.
2. Format
Exit
3. Parameters
The exit command has no parameters. After running the command, exit the system and enter the logon interface.
Last
1. Role
The last command is used to display the logon status of recent users or terminals. Its permission is granted to all users. Run the last command to view the log of the program. The administrator can find out who has tried 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 the Windows system, while Red Hat versions do not automatically load Vfat partitions. Therefore, manual operations are required.
Mount connects the Windows partition as a "file" of Linux to an empty folder in Linux to associate the Windows partition 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, the content of drive C in Windows is displayed in the/mnt/winc directory. Use a similar method to access the D and E disks of Windows. In Linux, Windows partitions are displayed in the following sequence: hda1 is drive C, hda5 is drive D, hda6 is drive E ...... And so on. In the above method, we can see that there is a big problem in Windows, that is, all Chinese file names or folder names in Windows are displayed as question marks "?". English is displayed normally. We can add some parameters to 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. After a flash disk is inserted, the flash disk is recognized as a SCSI disk. Generally, run the following command:
# Mount/dev/sda1/usb
You can mount the file system on the flash disk. ()