Tuesday, December 21, 2010

【 Weak current College 】 linux commonly used commands (bottom)



Shutdown and login command
login

Function: login is logged in the system, it is the usage rights for all users.
Syntax: login [name] [-p] [-h host name]
Note: If you choose to use the Linux command line mode login, then the first Linux command is login:.
General interface like this:
Linux2.4.20-8(linux)(10:36onSaturday,07August2004)
localhostlogin:root
password:

Parameters

-P: notification login environment parameters remain now.

-H: used to log on to the remote user name for the transfer.

Once logged in you will see the following interface:
Lastlogin:SatAug710:36:42onvc/1
Youhavenewmail.
[wzm@linuxwzm]$

shutdown

Feature: the role of the shutdown command to shut down the computer, its use is superuser privileges.
Syntax: shutdown [-h] [-I] [-k] [-m] [-t]
Description: the shutdown command to shut down the system safely. Some users will use direct cut off the power to close the Linux system, this is very dangerous. For Linux and Windows, its many processes running in the background, so forced shutdown may cause data loss in the process, so that the system in an unstable state, even in a system can damage hardware device (hard drive). In the system before using the shutdown command to shut down, the system administrator will notify all users who log on to the system will be shut off and login instructions will be frozen, that new users cannot log on again.

Parameters
-T: changing to a different runlevel tell init program before long after shutdown.
-K: not really shut down, just send a warning signal to each login.
-H: shutdown after power off.
-F: restart computer when forced fsck.
-Time: set the time before shutdown.
-M: the system into single-user mode.
-I: shutdown time display system information.

halt
Feature: the role of the halt command is to turn off the system, its use is superuser privileges.
Syntax: halt [-n] [-w] [-d] [-f] [-I] [-p]

Description: halt is called shutdown-h. Halt execution of the application process when they kill, do sync (will be stored in the buffer of data to force the write to your hard disk) system call, the file system write operation is complete will stop kernel. If the system run level 0 or 6, then shut down the system; otherwise the shutdown command (plus the-h switch) to replace.

Parameter description:
-N: prevent sync system call, it is used in the root partition using fsck patch, to prevent the kernel using the old version of super block overwrite patched the superblock.
-W: not really restart or shut down, just write wtmp (/var/log/wtmp) records.
-F: no calling shutdown and forced shutdown or restart.
-I: shutdown (or reboot), turn off all network interfaces.
-F: Force shutdown, not call shutdown of this directive.
-P: when the shutdown time by the way do turn off the power of action.
-D: turn off the system, but does not record.

reboot

Feature: the role of the reboot command to restart the computer, it uses the system administrator permissions.
Syntax: reboot [-n] [-w] [-d] [-f] [-I]
Parameter description:
-N: do not reboot the memory information is written back to disk.
-W: not really reboot, just put the record written to/var/log/wtmp file.
-D: not the record written to/var/log/wtmp file (-n this parameter contains a-d).
-I: reboot prior to all network related device stop.

mount
Feature: the role of the mount command is to load the file system, it is with the permissions of the root user or/etc/fstab users allowed in.
Syntax: mount-a [-fv] [-tvfstype] [-n] [-rw] [-F] devicedir
Description:
-H: show auxiliary information.
-A:/etc/fstab all files defined in the system hang up.
-F: this command is typically used together with-a, it will be for every mount action results in an itinerary. It needs to hang up a large number of NFS file systems can speed up the loading speed.

-F: typically used for debugging. It will make the mount does not perform the actual hanging on action, but the simulation process throughout the hang up, usually used in conjunction with-v.
-Tvfstype: displays the loaded file system type.
For example:
mountUSB
#mount/dev/sda1/mnt/usb
Mount a floppy disk:
mount-text2/dev/fd0/mnt/floppy
mountcdrom:
mount–tiso9660/dev/had/mnt/cdrom
montSCSIcdrom
mount-tiso9660/dev/sdb/mnt/scdrom

umount

Function: umount command is used to uninstall a file system, its use is the superuser or/etc/fstab users allowed in.
Syntax: unmount-a [-fFnrsvw] [-tvfstype] [-n] [-rw] [-F] devicedir
Description: umount command is the inverse of the mount command, its arguments and using the methods and mount commands are the same. Linux mount CD-ROM, CD-ROM will be locked, so you can't use CD-ROM Eject button on the Panel that pops up. However, when you no longer need to CD, if/cdrom as symbolic links, use umount/cdrom to uninstall it. Only when no user is using a CD, the order to be successful. The command included with the current working directory as a directory in the CD of the Terminal window.

exit

Feature: the role of the exit command to exit the system, it is the usage rights for all users.
Syntax: exit
Description: exit command has no parameters, the run after exit system login interface.

last

Feature: the role of the last command shows the current logon user or terminal, it is the usage rights for all users. Through the last command to view the program log, an administrator can learn who has been or is trying to connect to the system.
Syntax: 1ast [-n] [-ffile] [-ttty] [-h node] [-I-IP] [-1] [-y] [1D]

Parameters:

-N Specifies the number of output records.
-Ffile: file with the file specified as a query using a log file.
-Ttty: show only specified virtual console login.
-H node: show only specified logins on the node.
-IIP: show only specified IP logged on.
-1: use to display the remote IP address.
-Y: displays the records of the year, month, and day.
-ID: know the user name of the query.
-X: display system shutdown and user logon and exit.

Systems management related commands

The DF command
Function: displays the disk file system and usage
Syntax: df [option] ... [FILE]...
-A,--all displays all file system that contains file system with 0Blocks
--Block-size = {SIZE} {SIZE} size of Blocks
-H,--human-readable use 1024 for readability high format
-H,--si much like-h, but with 1000 units
-I,--inode information listed inodes
-K, set block-size = 1024
-L, only the local file system
-M, set block-size = 1048576
--Obtain disk usage information no-sync before using sync (preset)

-P,--use the POSIX output format portability
--Sync before obtaining disk usage information, using the sync will memory data is written to the disk
-T,--type = TYPE only lists the file system type of disk information
-T,--print-type displays the type of file system
-X,--exclude-type = TYPE not listed in the file system type of disk information
[root@linuxwzm]#df
/dev/hdc28064304840680681396811%/
/dev/hdc110108993248654610%/boot
/dev/hdc62016016776924113668041%/home
none12763201276320%/dev/shm
/dev/hdc715100324148413918403%/tmp
/dev/hdc52016016165955625404887%/usr
/dev/hdc350363162579260220122454%

Top command
Features: real-time display of dynamic process
Syntax: top [-] [ddelay] [q] [c] [S] [s] [n]
Parameters:
D: change display update rate.
Q: no delay display speed, super users top to highest priority execution
C: switching between two display modes: display file name; the full path and file name display
S: cumulative mode, will be completed or vanishing itinerary CPUtiMe accumulated
S: safe mode, interactive instruction to cancel, avoid potential crisis
I: does not show any idle (idle) or useless (zombie) trip
N: number of updates is completed will exit the top
B: combined with the use of the "n" parameter, you can set the top result is output to the file
Example: display update exit after ten times; top-n10
Crontab command
Function: crontab is used to let users in fixed time or fixed interval Executive program, in other words, that is similar to the consumer's time-table. -Uuser refers to setting specifies the user's time-table, this premise is that you must have the permissions (for example, is the root) can specify a schedule of others. If you do not use-uuser, is said to set their own schedule.
Syntax:
crontab[-uuser]filecrontab[-uuser]{-l|-r|-e}

Crontab command parameter:
-E: perform text editor to set a schedule, Slate's text editor is VI, if you want to use another text editor, please set the VISUAL environment variables to specify using the text editor (such as setenvVISUALjoe)
-R: delete current time table
-L: lists the current time-table
Time-table is formatted as follows:
f1f2f3f4f5program
Which is expressed in minutes, f1 f2 f3 for hours, said a month of the day, month, f4 f5 represents one day of the week. Program indicates that the program you want to perform.
When f1 is * indicates every minute to perform f2 * program, said every hour to execute the program, the rest of the analogy
When f1 is said from a-b a minute to b minutes this time f2 as you want to perform, said a-b from a to b hours to perform the remaining analogy

When f1 is */n time represents the time interval n minutes are executed once, f2 */n represents n hours a time interval is executed once, and so on
When f1 as a, b, c, ... When the a, b, c, ... Minutes to perform, f2 as a, b, c, ... When the a, b, c. .. Hours to perform the remaining analogy
Users can also set all of the first deposited in the archives file, used to set crontabfile schedule.
Example:
Each month the first hour of every day0 minutes once/bin/ls:
07***/bin/ls
In December, the daily 6 am to 12 pm, every 20 minutes to perform a/usr/bin/backup:
06-12/3*12*/usr/bin/backup

Monday to Friday 5: 00 p.m. every day, sent a letter to linux@linux.xab.ac.cn:
017**1-5mail-s"hi"linux@linux.xab.ac.cnname</tmp/maildata
Monthly daily midnight 0: 20 min, 2: 20 am, 4: 20 minutes .... do echo "haha"
200-23/2***echo"haha"

Note:

When the program in your specified time, the system will send a letter to you, show the contents of the program execution, if you do not wish to receive such a letter, on each row empty one cell with > > & 1/dev/null2.

Kill command

Function: kill a zombie process
Description: regular user can see all the system process, but they can only terminate their own process.
For example: to kill a process for 4112
$kill4112

Network operations command

Ifconfig

Function: to configure the network card
Syntax: ifconfig command has the following two formats:
ifconfig[interface]
ifconfiginterface[aftype]option|address…
Description: ifconfig first format (or used without any parameters in the ifconfig command) can be used to view the current system of network configuration.
For example:
$ifconfigeth0159.226.139.234netmask255.255.255.192up

Common options:
Hwclassaddr settings specify the MAC address of the interface device, the keyword must be followed by hardware name or its equivalent ASCII. Currently supported hardware types have ether, ax25, ARCnet and netrom.
Broadcastaddress broadcast address usually stems from network numbers by setting the host part of the all Member. Some IP's programme is different: this option can be applied to some strange environment (if you already set a broadcast address, ifconfig displays a BROADCAST flag).
Irqaddress settings specify the interface device uses interrupt line
Address settings for the specified interface on the device's IPaddress.
Dstaddradderss for PPP settings remote IP address, the pointopoint keyword available instead.

netstat
Function: displays network connections, routing tables, and network interface information, you can let the user know now what network connections are operational
Syntax: netstat [options]
Command options have the following meanings:
-A show all socket, including is listening.
-C every 1 second to reappear again until the user interrupt it.
-I show all network interface information, format with "ifconfig-e".
-N to network IP address instead of the name, network connection scenarios.
-R core routing table displayed in the format "with" route-e.
-T display TCP connection.
-U show connectivity of the UDP protocol.
-V display the work in progress.

nslookup

Function: nslookup command function is to query a machine's IP address and its corresponding domain name. It usually requires a domain name servers to provide domain name services. If the user has set up a domain name server, you can use this command to view the different host IP address corresponding to the domain name.
Syntax: nslookup [IP address/domain name]
[The cases] in the local machine using the nslookup command.
[root@linuxwzm]#nslookup159.226.139.234
Considerusingthe`dig’or`host’programsinstead.Runnslookupwith
the`-sil[ent]’optiontopreventthismessagefromappearing.
Server:159.226.139.1
Address:159.226.139.1#53
Non-authoritativeanswer:
234.139.226.159.in-addr.arpaname=linux.xab.ac.cn.
Authoritativeanswerscanbefoundfrom:
139.226.159.in-addr.arpanameserver=ms.xab.ac.cn.
ms.xab.ac.cninternetaddress=159.226.139.1

The ping command

Function: ping command is used to view the hosts on the network is working, it is sent to the host ICMPECHO_REQUEST package. Sometimes we think from the network of a host on the download file, but do not know the host is open, use the ping command to see.
Syntax: ping [options] hostname/IP address
Command options have the following meanings:
-C number in a specified number of packages sent and then stop.
-F large and quickly sending network packets to the machine and see its response.
-I seconds set intervals for a few seconds to send a network packet to a machine, the preset value is one second sent once.


-The number in a specified number of times l, the fastest way to send data packets to the specified machine (only root can use this option).
-Q does not display any information transmitted packets to only show the final result.
-R not directly through the gateway to send packets to a machine, usually a view native network interface.
-S bytes specify the number of bytes of data sent, the preset value is 56, plus 8 bytes of the ICMP header, the total is 64ICMP data bytes.
-D set the SO_DEBUG option.

Mail command
Function: read and send email
Syntax: mail [-iInv] [-ssubject] [-ccc-addr] [-bbcc-addr] user1 [user2 ...]
Description: mail not just one command, the mail or an e-mail program, for system managers mail is useful because the Manager can use mail to write script, regularly send some memos to remind users of the system.
Parameters:
I ignore the tty interrupt signal. (interrupt)
I forced set to interactive mode. (Interactive)
Print out the message, v for example courier location, status, and so on. (verbose)
N does not read mail.rc profile.
S message headers.
Ccc e-mail address.
Bbcc e-mail address

For example:

mailuser1@email.address
mailuser1@email.addressuser2
Mail-s title-cuser1user2 < mailtxt

Finger command

Function: finger command function is to query the user for information, usually displays a user in the system user name, home directory, dead time, login time, login shell, and other information. If you want to query the remote machine's user information, you will need a user name followed by "@ homeMachine name ", [username @ hostname] format, but you want to query the network hosts need to run the finger daemon.
Syntax: finger [options] [user] [-user @ host]
Command options have the following meanings:
-S show the user's name, real name, terminal name, write status, dead time, login time, and other information.
-L, in addition to using the-s option to display information, display the user's home directory, login shell, message status and other information, as well as the user's home directory .plan, .project and .forward files.
-P in addition does not display the .project file .plan file and, and-l options are the same.

For example,
[root@linuxwzm]#fingeryiluo
Login:yiluoName:(null)
Directory:/home/yiluoShell:/bin/bash
LastloginWedJul2115:39(CST)onpts/2from159.226.139.150
MaillastreadSatAug711:492004(CST)
NoPlan.

Backup and compress command
Users often need to backup the data in computer systems, in order to save storage space, often compressed backup file. The following introduction to backup and compression, respectively.

Tar command

Function: tar can be one of the files and directories created archives. Using tar, users can create a specific file (backup file) file, you can also change the file in the file, or to add new files. Tar was originally used to create files on tape, now users can create files on the device, such as a floppy disk. Using the tar command, you can put a bunch of files and directories all packaged into a file, this is the backup file or to combine several files into one file for easy network transmission is very useful. Linux tar is on the GNU version of the.
Syntax: tar [main options + auxiliary options] file or directory
Description: use this command, the main options is a must have, it tells the tar to do something, supported options are secondary use, you can choose.

Main options:
C to create a new profile. If users want to back up a directory or file, you should select this option.
R take to archive file is appended to the end of the archive file. For example, the user has already backed up files and found that there is a directory or file forget backup, you can use this option, you will forget the directory or file is appended to the backup file.
T list archives, see which files have been backed up.
U update files. In other words, use the new files replace the original backup files, if the backup file is not found in the file you want to update, it is appended to the last backup file.
X is released from the archive file.

Accessibility options:
B the option is set for the tape drive. Followed by a number, used to indicate the size of the block, the system default value is 20 (20 * 512bytes).
F use an archive file or device, this option is usually required.
K save existing files. For example, we put a file restore, the restore process, encountering the same file, will not be overwritten.
When you restore the file m, all file modification time is set to now.
To create multiple volumes of M-files documents, so that several disk storage.
V a detailed report on tar processing the file information. Without this option, the tar does not report file information.
W each step requires confirmation.
Z use gzip to Compress/decompress files, plus the option to compress the archive, restore must decompress it using this option.

For example,
The/home directory including subdirectories all backup files, the backup file is named test.tar.
$tarcvftes.tar/home
The/home directory including subdirectories all backup files and compressed backup file is named test.tar.gz.
$tarczvftest.tar.gz/home
To restore this backup file test.tar.gz and unzip
$tarzxvftest.tar.gz
View the contents of the backup file test.tar and split-screen display on the monitor.
$tartvftest.tar|more

Gzip command

Function: reduces the file size has two obvious benefits, one can reduce storage space and file transfer over the network, you can reduce transmission time. Gzip is on Linux systems often use a file compression and decompression of command, convenient and easy to use.
Syntax: gzip compression [options] (uncompressed) file name

Function: reduces the file size has two obvious benefits, one can reduce storage space and file transfer over the network, you can reduce transmission time. Gzip is on Linux systems often use a file compression and decompression of command, convenient and easy to use.
Syntax: gzip compression [options] (uncompressed) file name

Gzip command options:

-C will output wroteTo the standard output, and retain the original files.
-D will extract the compressed file.
-R recursive type to find the specified directory and all files in compressed or uncompressed.
-T test, check the compressed file is complete.
-V for each compression and decompression of files, displays the filename and compression ratio.
-Num num with the specified figures adjust compression speed,-1 or--fast represents the fastest compression method (low compression ratio),-9 or--best represents the slowest compression (high compression ratio). The system default value is 6

Gzip command

Suppose a directory beneath a file mm.txt, sort.txt, xx.com.
Example 1:/home directory on each of the files compressed into .gz files.
$cd/home
$gzip*
$ls
m.txt.gzsort.txt.gzxx.com.gz
Case study 2: putting an example 1 each extract compressed files, and lists the detailed information.
$gzip-dv*
mm.txt.gz43.1%-----replacedwithmm.txt
sort.txt.gz43.1%-----replacedwithsort.txt
xx.com.gz43.1%-----replacedwithxx.com
$ls
mm.txtsort.txtxx.com

Unzip command

Function: under compression software MSWindows winzip compressed file how to expand under Linux systems? you can unzip command, the command for the extension .zip compressed files.
Syntax: unzip [options] .zip compressed filename
The meaning of the various options are:
-X file list to extract the files, but not including, the specified file.
-V view compressed files directory, but are not extracted.
-T test files for damage, but are not extracted.
-D directory to the compressed file to the specified directory.
-Z show only note the compressed file.
-N do not overwrite existing files.
-O Overwrite the existing file and does not require user confirmation.
-J does not rebuild the directory structure of the document, extract all files into the same directory.

Example 1: a compressed file text.zip extract in the current directory.
$unziptext.zip
Example 2: a compressed file in the specified directory text.zip/tmp next unzip, if you have the same file exists, requires unzip command does not overwrite the original file.
$unzip-ntext.zip-d/tmp
Example 3: view compressed files directory, but are not extracted.
$unzip-vtext.zip






No comments:

Post a Comment