Linux Common commands

Source: Internet
Author: User
Tags create directory diff processing text stdin system log ftp protocol

Linux Getting Started Baidu Library: http://wenku.baidu.com/course/view/4fdf50e2524de518964b7d00Linux on a USB stick Http://zhidao.baidu.com/link?url=rFBh95J8tH1MnmB64is-3kiryYj2_75XADG15FT6O-IvVUoy_ VY9RM4WMUM0ZOOELVQZLZPXWMATEBPQV_Z1FACTRL + Z pause command lsLinux inside files and folders called Files -H number displays all files, including hidden files, in M or G as-I display file details-R large R recursive display subdirectory structure-ld [file name] Display directory and link information file [filename] Displays the type and information of the files touch creates a blank file such as  Create an existing file that will update the file's modified time CD directory switch:  The top level directory. Current directory ~ User home Directory-Previous working directory PWD current working directory CVD CP source file (clip) target file (clip)-R (for copy folder) recursively copy entire Directory-v Show details-p do not change file attributes mv Move, rename mv source file (clip ) target file (clip) move to current folder can rename-PRM delete file (folder)-R Delete folder (recursive delete)-I interactive-f force Delete, no warning prompt mkdir create directory-p recursive create rmdir delete an empty directory rm-r delete a non-empty directory
File system directory bin executable (called command) boot boot directory (and kernel) dev device files (devices are abstracted to files in Linux) etc all Profiles home directory (each user has a home directory), save user's file, Lib library file (phase When in Windows DLL) media mount peripherals such as CD-ROM and USB-disk opt are typically used to install large software proc systems with real-time information (only in memory) the first boot will be created:you can get the system Information/digital folder to take a process by viewing the contents of the file insideSbin only the root user can execute the file (or command) Super Binsys system The underlying information of the TMP temp directory, the contents will automatically delete USR general software installed here Var saves some information that will change frequently, there are logs, mailTimeDateRedefine the output format date +%y--%m--%d--can be changed to the other front to add the + number Date-s "20:20:20" Modified time Hwclock (clock) display hardware hour time CAL display Calendar uptime Watch the system run time view file Contents command Add File echo "What to Output" cat display the contents of the file More page to display the contents of the file (only page Down) less page to display the contents of the file (with page up and down)
Head to display the first few lines of the file (default 10 lines) Head-n 3 displays 3 rows tail display the end of the file (IBID.) (-F Trace Display file update used to view the log, the file update content will also be updated) View hardware information LSPCI View PC device-V  View Details LSUSB View USB device-V Ditto lsmod View loaded module (module =windows driver) shutdown, restart shutdown-h off-r Restart Example: Shutdown-h now shutdown shutdown-h +10 Shut down after 10 minutes shutdown-h 23:30 23:30 shutdown shutdown-r Now restart Poweroff immediate Shutdown Reboot Restart archive Now, compress zip new.zip myfile Compress myfile to new . zipunzip Myzip.zip gzip myfile Compression (gzip format) Iftar used to archive files, not compressed commands tar-cvf archived files (out.tar) files to be archived (clips) (etc) Tar-xvf myfile . Tar unpack archived files tar-cvzf backup.tar.gz/etc-z parameter Gizp compress archived files to reduce size TAR-ZXVF file.tar.gz extract Archive Compressed files
Find locatelocate quickly find files and folders, this command needs to establish a database, this command is to find files from the database, faster, updated daily, can only be found through the keyword locate keywordupdatedb update the database find Advanced Find File (clip) find finding location find parameter find location:. Represents the current directory/All files Find/-name *.conf look for a file named. conf format Find. -perm 777-perm represents a file with a permission of 777 find.   -type d file type D (folder) find.-name "A *"-exec ls-l {} \; -exec represents execution, will find the results passed to ls-l execution, except ls-l Other are fixed format find criteria-name name-perm permissions-user belong to a user-group belong to a group-CTime based on time-type type -size based on file size

Vimvim Command Direct start Vim is the enhanced version of VI, especially the path that supports the Guivim target file if the destination file exists, open if it does not exist and create

three modes of VIM:Command mode (normal mode) after startup, the default mode, any mode press ESC back to the command mode, you can complete the selection, copy, paste, undo and other operations in the Insert Mode Command mode Press "I" can enter, in the insert mode can be entered to edit the text content, ESC can return to the command mode EX mode Command mode Press ": "Can enter, enter ex mode, the cursor will move to the bottom, where you can save changes or exit VimCommand mode:I insert a text before the cursor o insert a new row below the current line dd Delete whole line yy put the current row into the buffer (copy) n+yy the contents of n rows into the buffer (copy n rows) p put the text in the buffer (paste) U undo the last action R replace the current character/find off   Key-word ex mode: W Save current modification: Q exit: q!   Force exit, do not save changes: X Save and exit equivalent: Wq:set number displays line numbers (or: Set NU):! The system command executes a system command and displays the result: SH switches to the command line and switches back to vim using ctrl+d


FDISK Partitioning tool Linux All devices are abstracted as a file, saved as the/dev directory under the hard drive device name General Hd[a-z] or sd[a-z] ([A-z]) as the partition number, such as Hda,hdb,sda,sdbide device is Hd[a-z],sata,  Scsi,sas, USB device sd[a-z] fdisk-l-H View hard disk information (h in units) FDISK/DEV/SDA partition the/DEV/SDA hard drive and enter the partition interface Partprobe let the kernel update the partition Table file system The operating system manages files and data through the file system, the disk or partition needs to create a file system before it can be used for the operating system, and the process of creating a file system is also known as formatting a device without a file system for a bare (raw) device mke2fs used to create a file system Mke2fs-t ext3/dev/ Sda2 parameter:-B blocksize Specify file system block Size-C check for bad blocks when setting up file System-L label Specify volume label-j establish file system log-t file type DUMPE2FS view file system information for partitions dumpe2fs/dev/ SDA1 E2label Add a label to the FileSystem E2LABEL/DEV/SDA1 Tool will change the label of the SDA1 tool FSCK check to repair the damaged file systemfsck/dev/sda2-Y does not prompt and directly fix corrupted data that is recognized as a file (file system has no records), FSCK will put the file into the Lost+found when the system starts, the disk will be fsck when the file system mount disk or partition creates a file system that needs to be mounted to a directory before it can be used. Windows will automatically mount, such as C drive, D drive MOUNT/DEV/SDB1 (partition to mount)/mnt (mount point, can be task directory) parameter:-t specifies the type of file system (which is automatically read by default)-o specifies the option to mount: RO, rw mount in read-only or read-write form, By default, Rwsync represents not using the cache, writing directly to disk async using the cache, by default Asyncnoatime the access time of the file is not updated each time the file is accessed atime the access time of the update file Remount re-mount the file system (multiple options with, separate) mount- o remount, Ro/dev/sdb1/mnt re-mount and set to read-only *mount-l view the mount point of the hard drive Umount unmount the mounted file system, Umount/dev/sda3 = UMOUNT/MNT if device is present is busy error, indicating that the file system is being used, unable to uninstall, view the file system process fuser-m/mnt The file is being used lsof/mnt automatic mount profile/etc/fstab used to define the file system that needs to be mounted automatically, the first line in the file represents a Mount configuration , the format is as follows:/dev/sda3/mnt ext4 defaults 0 0 Device mount point file system mount options that need to be mounted dump,fsck related options (the MOUNT-A command mounts the Auto-mount items defined in fstab)
The Help information for Linux command Plus-h or--helpls--HELP displays the help information for LS if the Help information shows ":" In the lower left corner to indicate that you can query input "/content" man + command Display Help for command-K find all commands with keywordsuser baseWhen using Linux, you need to log in as a user, a process also needs to run as a user, and the user's permissions can limit which resources the consumer or process can use and cannot use. -Each user has a userid, the operating system actually uses the user ID, not the user name-each user belongs to a primary group and belongs to one or more attached groups-each group has a groupid-each process runs as a user, and is subject to the resources that the user has access to restrict each file in the system to a user and group that belongs toThe User ID is 32 bits, starting with 0 and the user ID is limited to less than 60000:The user is divided into three kinds:-root User (ID 0 user is the root user)-system User (1-499)-Normal User (500 +) * Some devices also have their own ID, as the user use the ID command can display the current user's information related files:-/etc/passwd user's letter /etc/shadow-Save user's password-/etc/group save group Informationto view the logged on user:-whoami Displays the current user-who shows which users have logged on to the system-W shows which users are logged in and what they are doingTo create a user:-useradd user Name This command does the following: 1, add user information in/etc/passwd 2, if using passwd, password encryption is saved in/etc/shadow 3, create a new home directory for users/home/adduser4, will/etc/ The files in the Skel are copied to the user's home directory (there are some hidden files including the file that runs the command when you log off and the file of the command that is run at logon, you can manually create a file in Skel and all users have this file in their home directory) 5. Create a group with the same user name The new user belongs to this group by defaultTo Modify user information:-usermod parameter username parameter:-l new Username-u new userid-d User home directory Location-G user-owned primary group-G user-owned secondary group---Lock the user so that it cannot log on-u unlockDelete UserUserdel username Keep the user's home directory userdel-r username Delete the user's home directory at the same timeCreate, modify, delete groupsGroupadd groupnamegroupmod-n newname oldnamegroupmod-g newgid oldgid Group idgroupdel groupname file permissions in Linux, Three permissions per file:-R (Read)-W (write)-X (Execute)You must have RX permissions for the directory user, or you cannot browse the directory

Linux permissions are based on Ugo and the model is controlled:-U represents user,g on behalf of Group,o other-each file's permissions are set based on Ugo-permissions three a group (RWX), corresponding to Ugo set-each file has a owning user (U) and the owning group (G), does not belong to the file or group of Use O permission ls- l command Information (format) Ugo permissions link Number of user-owned group size time file name

Modify the file belongs to the user, group-chown change the user of the file: Chown user name File name-R (uppercase) recursively modifies all files in the directory-chgrp in the group that changed the file: CHGRP group name filename-R ditto Modify permission chmod mode file (-R can be modified recursively)-modulo Mode: U,g,o represents the user, group, and other A can refer to ugo+,-representatives to join or delete the corresponding permissions r,w,x represent three kinds of permissions example: chmod u+rw chenchmod g-x chenchmod go+r chenchmod a-x Chen Support for digital representation rights:-r = 4 (2^2)-X = 2 (2^1)-X = 1 (2^0) when using numbers to represent permissions, each group of permissions is the sum of corresponding numbers: RW = 4 +2 = 6rwx = 4+2+1 =7r-x = 4+1 =5chmod 660 Chen = = RW-RW----chmod 775 Chen = = rwxrwxr-xNetwork Basic ConfigurationLinux, named Eth0,eth1 on the internet,LSPCI Viewing PCI hardware informationLSUSB Viewing USB hardware informationIfconfig-a View so online interface information Ifconfig-eth0 View specific interface ifup eth0 turn on network card ifdown eth0   Turn off network Card Setup   Wizard Configure network address   NIC profile/etc/ Sysconfig/network-scripts/ifcfg-eth0dns configuration file/etc/resolv.conf static hostname profile/etc/hosts hostname configuration file/etc/sysconfig/network    Network Test network connectivity ping 192.168.1.1host www.baidu.comdig www.baidu.com display routing table IP route trace the network path to the destination address traceroute Www.baidu.com Network Quality test MTR www.baidu.com   Modify host name Permanent modification:/etc/sysconfig/network     Modify this file  centos 7   Configure IP with nmtui   command pipeline and redirect the command line Shell's data flow has the following definition:  name                   Description       number             default stdin           standard input        0             keyboard stdout         standard output     &NB Sp 1             terminal stderr         standard error       2             Terminal     Redirect: >  REDIRECT stdout to file (overwrite)  echo "abc" > outfile>>   ditto (append) 2>   redirect stderr to file (overwrite) 2>&1 Combining stderr with stdout   error and output will save <   REDIRECT StdIn   grep ABC </etc/passwd   (find ABC in passwd text) pipeline: |     stdout of one command as stdin    ls-l for another command | grep bingxing Linux command line Text Processing tool grep search text based on keywordgrep ' linuxcast '/etc/passwdfind/-user linuxcast | grep video-i ignores case-n Displays the result row-V output row with no keyword-A4 output results 4 rows after all rows-b2 the row of the output line before the 2 rowsCut-based column processing textCut-d:-f3/etc/passwd only shows passwd inside with: Separate third column grep linuxcast/etc/passwd | Cut-d:-f3-d Specifies the split character (default is tab)-f Specifies the output's column number-C is cut based on character Cut-c2-6/etc/passwd shows only 2nd to 6th charactersWC Text Statisticswc+ file name-L only counts the number of rows----only counts the number of words----only counts the count of the numbers in the number of characters the sort text sorts sort+ file names (non-Chinese)-R sort-N based on numbers sort-F ignore case-to-remove duplicate rows-TC use C as the delimiter to sort the columns-kx Specifies the right (x=?) when splitting a column based on a specified character. Column sort diff text compare diff linuxcast Linuxcast.net-i Ignore case-B ignore empty quantity change-u unified Display comparison information (typically used to generate patches) Diff-u Linuxcast linuxcast-new ;  Final.patch TR handles text content tr-d ' TMD ' < linuxcasttr ' A-Z ' A-Z ' < linuxcast sed to search for poor replacement text (using regular expressions) sed ' s/linux/unix/g '    Linuxcast s: Search g: Replace all sed ' 1,50s/linux/unix/g ' linuxcastsed-e ' s/linux/unix/g '-e ' s/nash/nash_su/g ' linuxcast Plus e can make multiple substitutions at the same time sed-f Sededit linuxcast Sededit can be a file, content is "content, do not write every time" contentRPM Installation Install software: rpm-i software.rpm uninstall software: Rpm-software upgrade form install: Rpm-u software-new.rpmrpm support install software via HTTP,FTP protocol RM-IVH HTTP://WWW.L INUXCAST.NET/SOFTWARE.RPM can add the following parameters:-V Display related information-h display progress bar Rpm-qa list all installed RPM software RPM-QF filename query destination file belongs to that RPM package Rpm-qi Packagen Ame query Specifies the installed RPM software Information rpm-ql packaname query specifies that the installed RPM software contains the files rpm-qip software.rpm query rpm file Information rpm-qlp software.rpm query rpm file contains the file guide Enter secret key: RPM--import rpm-gpg-key-centof-6 Verify rpm File: Rpm-k linuxcast--1.0-i-i386.rpm verify installed software rpm-v software

Linux Common 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.