Monday, June 3, 2013

Linux Beginners will learn the 60 commands

Linux will learn the commands Linux provides a large number of commands, which can effectively use a lot of work done, such as disk operations, file access, directory operations, process management, file permissions settings. So, working on a Linux system without using system commands. To truly understand the Linux system, you must learn from the Linux command by command based learning can be further understood Linux systems.
Different Linux distributions not the same as the number of commands, but at least Linux distributions also have more than 200 orders. Here I put the more important and most frequently used commands, according to their role in the system introduced one by one into the following six parts.
◆ Installation and login commands: login, shutdown, halt, reboot, install, mount, umount,      chsh, exit, last;
◆ file processing command: file, mkdir, grep, dd, find, mv, ls, diff, cat, ln;
◆ System Management Related commands: df, top, free, quota, at, lp, adduser, groupadd, kill, crontab;
◆ Network Operation Command: 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, who;
◆ Other commands: tar, unzip, gunzip, unarj, mtools, man, unendcode, uudecode.
In this paper, Mandrake Linux 9.1 (Kenrel 2.4.21) as an example, under Linux installation and login commands.
login
1 action
login role is to log into the system, and its use permissions to all users.
(2) Format
login [name] [-p] [-h hostname]
3 main parameters
-P: Notification login to maintain the current environmental parameters.
-H: is used to transfer between remote login user name.
If you choose to use Linux command line login, then see the first Linux command is login:.
General Interface is this:
Manddrake Linux release 9.1 (Bamboo) for i586
renrel 2.4.21-0.13mdk on i686/tty1
localhost login: root
password:
The above code, the first line is Linux distribution version number, the second line is the kernel version number and login virtual console, in the third line we enter the login name and press "Enter" key to enter the account password in the Password, you can login system. For security reasons, enter the account password characters are not echoed on the screen, the cursor does not move.
Login will see the following screen (with super user):
[Root @ localhost root] #
last login: Tue, Nov 18 10:00:55 on vc/1
Above the display is logged week, month, date, time, and use the virtual console.
4 Application Tips
Linux is a true multi-user operating system, you can also accept multiple user logins, but also allows a user to log in multiple times. This is because many versions of Linux and Unix, as provides a virtual console access method, allowing users at the same time from the console (the system console is directly connected with the system monitor and keyboard) for multiple logins. Each virtual consoles can be seen as a stand-alone workstation, the table can be switched between.Switching virtual console by pressing the Alt key and a function key to achieve, usually using F1-F6.
For example, users log in, click "Alt + F2" key, the user can see the above message appears "login:" prompt, indicating that the user sees the second virtual console. Then simply press "Alt + F1" key, you can return to the first virtual console. A newly installed Linux system allows users to use "Alt + F1" to "Alt + F6" key to access the first six virtual consoles. Virtual Console most useful is that when a program error caused a system deadlock, you can switch to another virtual console work, close the program.
shutdown
1 action
shutdown command is to shut down the computer, it is the superuser permissions.
(2) Format
shutdown [-h] [-i] [-k] [-m] [-t]
3 Important Parameters
-T: changing to another run level before telling init program how long after the shutdown.
-K: do not really shutdown, only to send warning signals to each registrant.
-H: power off after shutdown.
-C: cancel current process to cancel the shutdown process is currently running. So this option is of course no time parameters, but you can enter a message to explain, and this information will be sent to each user.
-F: when you restart the computer forced fsck.
-Time: the time before setting off.
-M: the system to single-user mode.
-I: Displays system information when shutdown.
4 Command Description
shutdown command can be safely shut down the system. Some users will use a direct way to shut off the power and Linux systems, this is very dangerous.Because Linux and Windows, which many processes running in the background, so the forced shutdown process may lead to data loss, so that the system is in an unstable state, and even in some systems will damage the hardware device (hard drive). Before shutting down the system using the shutdown command, the system administrator will notify all registered users of the system to shut down, and login instructions will be frozen, that new users can not log on.
halt
1 action
halt command is to shut down the system, it is the superuser permissions.
(2) Format
halt [-n] [-w] [-d] [-f] [-i] [-p]
3 Main Parameter Description
-N: to prevent the sync system call, it is used in repair with fsck the root partition, to prevent the kernel with the old version of the super-block cover patched superblock.
-W: not really restart or shut down, just write wtmp (/ var / log / wtmp) record.
-F: do not call shutdown, while the forced shutdown or restart.
-I: shutdown (or reboot) before, turn off all network interfaces.
-F: forced shutdown, this directive does not call shutdown.
-P: the way to do it when the shutdown power off action.
-D: shut down the system, but does not leave a record. 
4 Command Description
halt is to call shutdown-h. halt execution, kill the application process, perform sync (to the data stored in the buffer is written to disk in compulsory) system call, file system write operation is completed will stop the kernel. If the system run level is 0 or 6, then shut down the system; otherwise to the shutdown command (plus-h parameter) instead. 
reboot
1 action
The role of the reboot command to restart the computer, it is the system administrator permission.
(2) Format
reboot [-n] [-w] [-d] [-f] [-i]
3 main parameters
-N: do not do before rebooting the hard drive memory data write-back operation.
-W: does not really re-boot, just put the records are written to / var / log / wtmp file.
-D: do not put records are written to / var / log / wtmp file (-n This parameter contains a-d).
-I: in before the first reboot all network-related device to stop.
install
1 action
The role of the install command to install or upgrade your software or backup data, its use permissions to all users.
(2) Format
(1) install [option] ... Source Destination
(2) install [option] ... SOURCE ... DIRECTORY
(3) install-d [option] ... directory ...
In the first two formats, will <source> Copy to <destination> or put more <source> file copied to an existing <Menu>, while setting permission modes and owner / group. In the third format, create all the specified directories and their home directory. The parameters of long options are mandatory for short options too necessary.
3 main parameters
- Backup [= CONTROL]: for each existing destination file backup.
-B: like - backup, but does not accept any parameters.
-C: (This option is not processed).
-D, - directory: all arguments as directory names, and will create the specified directory of all home directories.
-D: Create <destination> in front of all the main directory, and then put <source> Copy to <destination>; using the format in the first useful.
-G, - group = Group: set group ownership, instead of process' current group.
-M, - mode = mode: Self-setting permission modes (like chmod), instead of rwxr-xr-x.
-O, - owner = Owner: set ownership (super-user only applicable).
-P, - preserve-timestamps: the <source> file access / modification time as the corresponding destination file time attributes.
-S, - strip: a strip command removes symbol table, only applies to the first and second use format.
-S, - suffix = suffix: specify your own backup files <suffix>.
-V, - verbose: processing each file / print the name of the directory.
- Help: show this help message and exit.
- Version: Display version information and exit.
mount
1 action
mount command is to load the file system, it is the super-user with privileges or / etc / fstab allowed users.
(2) Format
mount-a [-fv] [-t vfstype] [-n] [-rw] [-F] device dir
3 main parameters
-H: displays auxiliary information.
-V: Displays information, usually used for debugging and-f.
-A: the / etc / fstab file systems defined in all hang.
-F: This command is usually used in conjunction with-a, it will mount for every action produces a stroke is responsible for implementation. The system needs to mount a large number of NFS file system can accelerate the speed of loading.
-F: typically used for debugging. It will mount does not perform the actual hanging of action, but to simulate the whole process of hanging, usually used in conjunction with the-v.
-T vfstype: Display the loaded file system type.
-N: Generally, mount will hang in the /etc/mtab to write a data in the system can be written to the file system is not the case, you can use this option to cancel this action.
4 Application Tips
On Linux and Unix systems, all files are as a large tree (with / as root) part of the visit. To access the files on the CD-ROM, CD-ROM devices need to be mounted in a hanging file tree decorated. If the release is installed automatically mount package, then this step can be performed automatically. In Linux, if you want to use the hard disk drives and other storage devices, you have to put it loaded hung up when the storage device, you can use it as a directory to access. Mount a device using the mount command. Use the mount command in this, at least first know the following three types of information: the object to load the file system type, the device name of the object to be loaded and should equipment be loaded into which directory.
(1) Linux file system can be identified
◆ Windows 95/98 used FAT 32 file system: vfat;
◆ Win NT/2000 file system: ntfs;
◆ OS/2 file system used: hpfs;
◆ Linux file system used: ext2, ext3;
◆ CD-ROM disc with a file system: iso9660.
Although vfat is FAT 32 system, but in fact it is also compatible with FAT 16 file system type.
(2) determine the name of the device
In Linux, the device name is usually present in / dev. These devices are all named after the name of the rule, you can use the "reasoning" way to find out the device name. For example,     /dev/hda1 this IDE devices, hd is the Hard Disk (HDD) is, sd is a SCSI Device, fd is Floppy Device (or Floppy Disk?). A represents a first device, usually IDE connector can connect four IDE devices (such as four hard drives). Therefore, a method to identify the IDE hard disk difference is hda, hdb, hdc, hdd. hda1 in the "1" hda represents the first hard disk partition (partition), hda2 hda represents a second primary partition, the first logical partition from hda5 start, and so on. Additionally, you can directly check the / var / log / messages file can be found in the file system after the computer boot device code has recognizable.
(3) Find a mount point
Before the decision to mount the equipment, first look at the computer is not there a / mnt empty directory, which is specifically used as a mount point (Mount Point) directories. Recommended /mnt built in several /mnt/cdrom, /mnt/floppy, /mnt/mo etc. directory, as a dedicated mount point directory. For example, if you want to mount the following five devices, which executes instructions may be as follows (assuming all the Linux ext2 system, if it is Windows XX Please change the ext2 vfat):
Floppy ===> mount-t ext2 /dev/fd0 /mnt/floppy
cdrom ===> mount-t iso9660 /dev/hdc /mnt/cdrom
SCSI cdrom ===> mount-t iso9660 /dev/sdb /mnt/scdrom
SCSI cdr ===> mount-t iso9660 /dev/sdc /mnt/scdr
But now most newer Linux distributions (including Red Flag Linux, the soft Linux, Mandrake Linux, etc.) can be automatically mounted file system, but other than Red Hat Linux.
umount
1 action
umount command is to uninstall a file system, it is the superuser permissions or / etc / fstab allowed users.
(2) Format
unmount-a [-fFnrsvw] [-t vfstype] [-n] [-rw] [-F] device dir
3 Instructions for use
mount command umount command is the inverse operation, its parameters and the use of methods and the mount command is the same. Linux mounted the CD-ROM, it will lock the CD-ROM, CD-ROM so can not be used on the front panel Eject button to eject it. However, when the disc is no longer needed, if has / cdrom as a symbolic link, use the umount / cdrom to unmount it. Only when no user is using a disc, the command to succeed. The command includes the current working directory with the CD-ROM directory as the terminal window.
chsh
1 action
chsh command is to change the user shell settings, and its use permissions for all users.
(2) Format
chsh [-s] [-list] [- help] [-v] [username]
3 main parameters
-L: show all Shell type.
-V: Displays Shell version number.
4 Application Tips
In front of Linux has a variety of Shell, general default is Bash, if you want to replace Shell types can use the chsh command. First enter the account password, and then enter the new Shell type, if done correctly the system displays "Shell change". Its interface is generally as follows:
Changing fihanging shell for cao
Password:
New shell [/bin/bash]:/bin/tcsh
The above code, [] is currently used within Shell. Ordinary users can modify their own Shell, the super user can modify all the user's Shell. To query system which Shell, you can use the chsh-l command, shown in Figure 1.
Figure 1 system can use the Shell type
As can be seen from Figure 1, the author of the system can be used with Shell bash (the default), csh, sh, tcsh of four.
exit
1 action
The role of the exit command to exit the system and its use permissions to all users.
(2) Format
exit
3 Parameters
exit command with no arguments, exit the system after running into the login screen.
last
1 action
last command is to display recent user or terminal logins, its use permissions to all users. By last command to view the program's log, the administrator can be informed of who has ever or attempted connection system.
(2) Format
1ast [-n] [-f file] [-t tty] [-h node] [-I-IP] [-1] [-y] [1D]
3 main parameters
-N: Specifies the number of output records.
-F file: Specifies the file with the file used as the query log file.
-T tty: shows only the specified virtual console logins.
-H node: Displays only the specified node logins.
-I IP: Show only specified IP logged on the case.
-1: Used to display the remote IP address.
-Y: Show record year, month, and day.
-ID: know the user name queries.
-X: Display system shutdown, user log in and out of history.
Hands-on exercises
The above describes the Linux installation and login commands, the following are a few examples of what I just talked about hands-on exercises command.
1 run multiple commands
In a command line, you can execute multiple commands, the individual commands are separated by semicolons can be, for example:
# Last-x; halt
The above code means that the display system shutdown, user login and shut down the computer after exiting history.
2 Use mount to mount the file system access to Windows system
Many Linux distributions can now be automatically loaded Vfat partition to access the Windows system, and various versions of Red Hat are not automatically loaded Vfat partition, it also needs to be done manually.
can mount a Windows partition as a Linux "file" attached to Linux an empty folder, thus bringing the Windows partition and / mnt This directory link. Therefore, as long as access to the folder is equivalent to access the partition. First in the / mnt folder created under winc at the command prompt, enter the following command:
# Mount-t vfat / dev/hda1 / mnt / winc
Means that the C partition for Windows Liunx linked to the / mnt / winc directory. Then, in the / mnt / winc directory in Windows, you can see the contents of the C drive. Using a similar method can access the Windows system D, E drive. In the Linux system displays the Windows partition general order this: hda1 as the C drive, hda5 for the D drive, hda6 as E drive ...... and so on. The method can view the Windows system has a big problem, that is, all the Chinese in Windows file names or folder names appear as a question mark "?", But they can be displayed in English. We can add some parameters to make it display Chinese. Also to the operation of the above example, then enter the command:
# Mount-t vfat-o iocharset = cp936 /dev/hda1 /mnt/winc
Now it can properly display Chinese.
3 Use the mount to add a file system on the flash drive
Under Linux flash drive is very simple to use. Linux on the USB device has good support, when inserted flash drive, flash drive is recognized as a SCSI disk, usually enter the following command:
# mount /dev/sda1 /usb
Will be able to add a file system on the flash drive. ()

No comments:

Post a Comment