Linux Common Command Daquan

Source: Internet
Author: User
Tags gpg rar recode nslookup rsync

Linux Common Command Daquan
System Information The processor architecture of the Arch Display Machine (1) UNAME-M display the processor architecture of the Machine (2) uname-r display the kernel version dmidecode-q display hardware system parts-(SMBIOS/DMI) hdparm-i/dev/ HDA lists the architecture characteristics of a disk HDPARM-TT/DEV/SDA perform a test read operation on disk cat/proc/cpuinfo display information about CPU Info cat/proc/interrupts display Interrupt Cat/proc/memi NFO Check memory use Cat/proc/swaps show which swap is used cat/proc/version display kernel version cat/proc/net/dev display network adapter and statistics cat/proc/mounts show loaded file system Lspci-tv List of PCI devices LSUSB-TV display USB device date display system Day Cal 2007 Display 2007 Calendar table date 041217002007.00 set the day and time-month day year. Seconds clock-w Time changes saved to BIOS


Shutdown (System shutdown, restart, and logout) Shutdown-h now shutdown system (1) INIT 0 shutdown system (2) Telinit 0 Shutdown System (3) shutdown-h Hours:minutes & Shut down system by scheduled time shut Down-c Cancel the system at a predetermined time Shutdown-r now restart (1) reboot restart (2) Logout logoff


Files and directories  cd/home into the '/home ' directory '  CD. Return to the previous level of directory  CD: /.. Return to the top level two directory  CD enter the personal home directory  CD ~user1 into the personal home directory  CD-return to the last directory  pwd show work path  ls view files in directory  ls-f View files in a directory  ls-l display file and directory details  ls-a show hidden files  ls *[0-9]* display filenames and directory names containing numbers  tree display files and directories starting with the root directory tree (1)  lstree displaying files and directories starting with the root directory tree (2)  mkdir Dir1 Create a directory called ' Dir1 '  mkdir dir1 dir2 Create two directories at the same time  mkdir-p/tmp/ DIR1/DIR2 Create a directory tree  rm-f file1 Delete a file called ' file1 '  rmdir dir1 Delete a directory called ' Dir1 '  rm-rf dir1 delete a name called ' Dir1 ' Directory and delete its contents simultaneously  rm-rf Dir1 DIR2 Delete two directories and their contents  MV dir1 new_dir rename/move a directory  CP file1 file2 copy a file  CP dir/* . Copy all files under a directory to the current working directory  cp-a/tmp/dir1. Copy a directory to the current working directory  cp-a dir1 dir2 copy a directory  ln-s file1 lnk1 Create a soft link to a file or directory  ln file1 lnk1 Create a physical link to a file or directory   Touch-t 0712250000 File1 Modify the timestamp of a file or directory-(YYMMDDHHMM)  file file1 outputs the MIME type of the file as Text icon V-L lists the known encodings  iconv-f fromencoding-t toencodingInputfile > OutputFile creates a new from the given input file by assuming it's encoded in fromencoding and converting it to Toencoding. find. -maxdepth 1-name *.jpg-print-exec Convert "{}"-resize 80x60 "thumbs/{}" \; Batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick) &NB Sp


File search Find/-name file1 from '/' Start into root filesystem search files and directories find/-user User1 search for files and directories belonging to user ' User1 ' find/home/user1-name \*.bin in Directory '/home/user1 ' search for files with '. bin ' at the end of Find/usr/bin-type f-atime +100 search execution files that have not been used in the last 100 days Find/usr/bin-type f-mtime-10 Search A file created or modified within 10 days Find/-name \*.rpm-exec chmod 755 ' {} '; Search for files ending with '. RPM ' and define their permissions find/-xdev-name \*.rpm search for files ending with '. RPM ', ignoring the removable devices such as optical drives, locate \*.ps looking for files ending with '. ps '-run ' update first ' DB ' command Whereis halt displays the location of a binary file, source code, or man which halt displays the full path of a binary or executable file


mount a file system mount/dev/hda2/mnt/hda2 mount a disk called hda2-ok directory '/mnt/hda2 ' already exists umount/dev/hda2 uninstall a disk called Hda2-first from Mount point '/mnt/hda2 ' Exit Fuser-km/mnt/hda2 when the device is busy forcing the unload Umount-n/mnt/hda2 run the unload operation without writing to the/etc/mtab file-very useful when the file is read-only or when the disk is full Mount/dev/fd0/mnt/flo Ppy mount a floppy disk mount/dev/cdrom/mnt/cdrom mount a cdrom or dvdrom Mount/dev/hdc/mnt/cdrecorder mount a CDRW or dvdrom mount/dev/hdb/mnt /cdrecorder mount a CDRW or dvdrom Mount-o loop file.iso/mnt/cdrom mount a file or ISO image file mount-t vfat/dev/hda5/mnt/hda5 mount a Windows FAT32 file System Mount/dev/sda1/mnt/usbdisk mount a USB disc or flash device mount-t smbfs-o username=user,password=pass//winclient/share/m Nt/share to mount a Windows network share


Disk space Df-h Displays the list of partitions that have been mounted LS-LSR |more to arrange files and directories in size du-sh dir1 estimate directory ' Dir1 ' already used disk space ' Du-sk * | SORT-RN displays the size of the file and directory according to capacity rpm-q-a--qf '%10{size}t%{name}n ' | SORT-K1,1N the space used by the installed RPM package (Fedora, Redhat class System) dpkg-query-w-f= ' ${installed-size;10}t${package}n ' on a per-size basis | SORT-K1,1N Displays the space used by the installed Deb package based on size (Ubuntu, Debian System)
Return Top Index ^
Users and Groups Groupadd Group_name create a new user group Groupdel group_name Delete a user group Groupmod-n new_group_name old_group_name Rename a user group Useradd -C "Name Surname"-G admin-d/home/user1-s/bin/bash user1 Create a user belonging to the "admin" user group Useradd user1 create a new user Userdel-r User1 Delete a user ('-R ' exclude home directory) usermod-c "User FTP"-G system-d/ftp/user1-s/bin/nologin user1 Modify the Users Properties passwd change Password passwd user1 Modify a user's password (root only) chage-e 2005-12-31 user1 set the expiration period of the user password Pwck check the file format and syntax correction of '/etc/passwd ' and the presence of user grpck check '/etc/passwd ' File format and syntax corrections as well as the presence of groups Newgrp Group_name login into a new group to change the preset group of newly created files
Return Top Index ^
File permissions-use "+" to set permissions, use "-" to suppress LS-LH display permissions Ls/tmp | Pr-t5-w$columns divides the terminal into 5 columns to display chmod ugo+rwx Directory1 The owner of the Directory (U), Group (g), and others (O) to read (R), write (W), and execute (x) permissions chmod GO-RWX Director Y1 Delete Group (g) Read and write execution permissions to the directory with others (O) chown user1 file1 Change the Owner property of a file Chown-r user1 directory1 Change the owner property of a directory and change the properties of all files in the directory at the same time CHGRP GR Oup1 file1 change a file's group Chown user1:group1 File1 Change the owner and group properties of a file Find/-perm-u+s lists all files in a system that use Suid control chmod u+s/bin/file1 Set SUID bit of a binary file-the user who is running the file is also given the same permissions as the owner chmod u-s/bin/file1 Disable SUID bits of a binary chmod g+s/home/public setting a directory Sgid bit-similar to Su ID, but this is the chmod g-s/home/public Disable a directory for the SGID bit chmod o+t/home/public set a file STIKY bit-only allow legitimate owners to delete files chmod o-t/home/ Public disables the STIKY bit of a directory
Return Top Index ^
Special properties of the file-use "+" to set permissions, use "-" to cancel Chattr +a file1 only allow append to read and write files chattr +c file1 allow this file to be automatically compressed/decompressed by the kernel chattr +d file1 in file system backup , the DUMP program ignores this file chattr +i File1 is set to an immutable file, cannot be deleted, modified, renamed, or linked chattr +s file1 allows a file to be safely deleted chattr +s File1 Once the application writes to the file, Make the system immediately write the result of the modification to disk chattr +u file1 If the file is deleted, the system will allow you to restore the deleted file later lsattr display special properties
Return Top Index ^
Package and Compress files  bunzip2 file1.bz2 extract a file called ' file1.bz2 '  bzip2 file1 compress a file called ' file1 '  gunzip file1.gz unzip a called ' file1.gz ' file  gzip file1 compress a file called ' file1 '  gzip-9 file1 to maximize compression  rar a File1.rar test_file create a called ' File1.rar ' Package  rar a file1.rar file1 file2 dir1 simultaneously compress ' file1 ', ' file2 ' and directory ' Dir1 '  rar x File1.rar extract rar package  unrar x file 1.rar decompression rar Package  TAR-CVF Archive.tar file1 Create a non-compressed TARBALL TAR-CVF archive.tar file1 file2 dir1 Create a containing ' file1 ', The ' file2 ' and ' dir1 ' files  TAR-TF Archive.tar show the contents of a package  TAR-XVF Archive.tar release a package  TAR-XVF archive.tar-c/TM P Release the compressed package to the/tmp directory  TAR-CVFJ archive.tar.bz2 dir1 Create a bzip2 format of the compressed package  TAR-XVFJ archive.tar.bz2 Extract a bzip2 format of the compressed package & NBSP;TAR-CVFZ archive.tar.gz Dir1 Create a zipped package in gzip format  TAR-XVFZ archive.tar.gz unzip an gzip compressed package  zip file1.zip File1 Create a ZIP-format compression package  zip-r file1.zip file1 file2 dir1 to compress several files and directories into a zip-format package  unzip File1.zip unzip a zip-format tarball  
Return Top Index ^
RPM Packages-(Fedora, Redhat and similar systems)  RPM-IVH package.rpm Install an RPM package  RPM-IVH--nodeeps package.rpm Install an RPM package and ignore dependency warnings &NB Sp;rpm-u package.rpm Update a RPM package without changing its profile  rpm-f package.rpm update one to determine which RPM package has been installed  rpm-e package_name.rpm remove an RPM package & NBSP;RPM-QA display all installed RPM packages in the system  rpm-qa | grep httpd shows all RPM packages with the words "httpd" in their names  rpm-qi package_name get special information about an installed package  RPM-QG "System environment/daemons" display RPM Package for a component  rpm-ql Package_name displays a list of files provided by an already installed RPM package  RPM-QC Package_name shows a list of profiles provided by an already installed RPM package  rpm-q Package_name--whatrequires shows a list of dependencies that exist with a RPM package  rpm-q package_name--whatprovides shows the volume of a RPM package  rpm-q Package_name--scripts shows the script executed during installation/removal l rpm-q Package_name--changelog shows a modified history of the RPM package  rpm-qf/etc/httpd/ Conf/httpd.conf confirm that the given file is provided by which RPM package  rpm-qp package.rpm-l displays a list of files provided by a RPM package that has not been installed  rpm--import/media/cdrom/ Rpm-gpg-key Import Public key digital certificate  rpm--checksig package.rpm confirm the integrity of an RPM package  RPM-QA Gpg-pubkey confirm the integrity of all RPM packages installed  rpm-v Package_name InspectionFile size, license, type, owner, group, MD5 check, and last modified time  rpm-va check all installed RPM packages in the system-use  RPM-VP package.rpm to verify that an RPM package is not installed   Rpm2cpio package.rpm | Cpio--extract--make-directories *bin* Run executable file from an RPM package  rpm-ivh/usr/src/redhat/rpms/' arch '/package.rpm Install a built-in package from a RPM source  rpmbuild--rebuild package_name.src.rpm build an RPM package from one RPM source  
Return Top Index ^
Yum Package Upgrade-(Fedora, Redhat and similar systems) yum install package_name download and install a RPM package Yum Localinstall package_name.rpm will install an RPM package using your own Software warehouse for you to resolve all dependencies Yum Update package_name.rpm updates all installed RPM packages in the current system Yum Update package_name update an RPM package yum remove Package_name Delete an R  PM Package Yum list lists all packages installed in the current system Yum Search Package_name Search package in rpm repository Yum clean packages cleanup RPM Cache Delete downloaded package Yum Clear headers Delete all header files Yum Clean all deletes all cached packages and header files
Return Top Index ^
Deb Package (Debian, Ubuntu and similar systems) dpkg-i package.deb Install/update a deb package dpkg-r package_name remove a deb package from the system dpkg-l display all installed de in the system B-Pack Dpkg-l |  grep httpd displays all of the Deb packages with the words "httpd" in their names dpkg-s package_name get information on a special package already installed in the system dpkg-l package_name display a list of files provided by a Deb package already installed in the system Dpkg--contents Package.deb shows a list of files provided by a package that has not yet been installed Dpkg-s/bin/ping confirm which Deb package the given file is provided by
Return Top Index ^
APT software tools (Debian, Ubuntu and similar systems) apt-get install Package_name installs/updates a Deb package apt-cdrom install Package_name from CD installation/update a Deb Package Apt-get Update upgrade list of packages Apt-get upgrade upgrade all installed software apt-get remove package_name Delete a Deb package from the system apt-get check confirm dependent repositories correct AP T-get clean clears the cache from the downloaded package Apt-cache search Searched-package Returns the package name that contains the string you want to search
Return Top Index ^
View the contents of a file cat file1 the contents of the file from the first byte to view the content of the files. Tac File1 View the contents of a file in reverse from the last line more file1 view the contents of a long file less file1 similar to the ' more ' command, but it allows in the file and the positive Reverse operation to the same head-2 File1 view the first two lines of a file Tail-2 file1 view the last two lines of a file tail-f/var/log/messages real-time view of what was added to a file
Return Top Index ^
Text processing  cat file1 file2 ... | Command <> File1_in.txt_or_file1_out.txt general syntax for text manipulation using PIPE, STDIN and Stdout cat file1 | Command (SED, grep, awk, grep, etc ...) > Result.txt Merge the detailed description text of a file and write the introduction to a new file  cat File1 | Command (SED, grep, awk, grep, etc ...) >> Result.txt Merge The detailed description text of a file and write the introduction to an existing file  grep aug/var/log/messages in Find the keyword " grep" in the file '/var/log/messages ' ^aug/var/log/messages in the file '/var/log/messages ' to find words that begin with " grep" [ 0-9]/var/log/messages Select all rows in the '/var/log/messages ' file that contain numbers  grep aug-r/var/log/* Search the directory '/var/log ' and subsequent directories for the string "" " Nbsp;sed ' s/stringa1/stringa2/g ' example.txt replace ' string1 ' in Example.txt file with ' string2 '  sed '/^$/d ' example.txt Remove all blank lines from the Example.txt file  sed '/*#/d; /^$/d ' Example.txt Remove all comments and blank lines from the Example.txt file  echo ' Esempio ' | TR ' [: Lower:] ' [: Upper:] ' merge up and down cell contents  sed-e ' 1d ' result.txt exclude first line from file Example.txt  sed-n '/stringa1/p ' view contains only words " String1 "line  sed-e ' s/*$//' ExampLe.txt Delete the last white space character of each line  sed-e ' s/stringa1//g ' example.txt only remove the word "string1" from the document and leave all remaining  sed-n ' 1,5p;5q ' Example.txt view from the first line to the 5th row  sed-n ' 5p;5q ' example.txt view line 5th  sed-e ' s/00*/0/g ' example.txt replace multiple 0  cat-n with a single 0 File1 number of lines to mark a file  cat example.txt | awk ' nr%2==1 ' deletes all even lines in the Example.txt file  echo a b C | awk ' {print '} ' view one row first column  echo a b C | awk ' {print $1,$3} ' view the first and third columns of a row  paste file1 file2 merge two files or two columns of content  paste-d ' + ' file1 file2 merge two files or two columns of content, the middle with "+" distinguish &N Bsp;sort file1 file2 Sort the contents of two files  sort file1 file2 | Uniq Remove the set of two files (duplicate lines retain only one copy)  sort file1 file2 | Uniq-u Delete intersection, leave other lines  sort file1 file2 | Uniq-d Remove the intersection of two files (leaving only the files that exist in two files)  comm-1 file1 file2 Compare the contents of two files only delete the contents of ' File1 '  comm-2 file1 file2 compare two files within Allow to delete only the content contained in ' File2 '  comm-3 file1 file2 Compare the contents of two files delete only two files in common  
Return Top Index ^

Character settings and file format conversion Dos2unix filedos.txt fileunix.txt Convert a text file format from Msdos to UNIX Unix2dos fileunix.txt Converts the format of a text file from UNIX to Msdos Recode. HTML < page.txt > page.html Convert a text file to HTML Recode-l | More Show all allowable conversion formats
Return Top Index ^
File system Analysis Badblocks-v/dev/hda1 check for bad blocks on disk hda1 fsck/dev/hda1 repair/Check the integrity of the Linux file system on HDA1 disk FSCK.EXT2/DEV/HDA1 repair/ Check the integrity of the Ext2 file system on the HDA1 disk E2FSCK/DEV/HDA1 repair/Check hda1 the integrity of the Ext2 file system on the disk e2fsck-j/dev/hda1 repair/Check hda1 the integrity of the Ext3 file system on the disk FSCK.EXT3 /DEV/HDA1 Repair/Check the integrity of the Ext3 file system on the HDA1 disk FSCK.VFAT/DEV/HDA1 repair/Check the integrity of the FAT file system on the HDA1 disk FSCK.MSDOS/DEV/HDA1 repair/ Check the integrity of the DOS file system on the HDA1 disk DOSFSCK/DEV/HDA1 repair/Check the integrity of the DOS file system on the HDA1 disk
Return Top Index ^
Initialize a file system mkfs/dev/hda1 create a file system on the HDA1 partition mke2fs/dev/hda1 create a Linux ext2 file system in the HDA1 partition mke2fs-j/dev/hda1 create a Linux in the HDA1 partition Ext3 (journaled) file system mkfs-t VFAT 32-f/dev/hda1 Create a FAT32 file system fdformat-n/dev/fd0 format a floppy disk Mkswap/dev/hda3 create a swap file system
Return Top Index ^
Swap file system Mkswap/dev/hda3 Create a swap file system Swapon/dev/hda3 enable a new swap file system SWAPON/DEV/HDA2/DEV/HDB3 enable two swap partitions
Return Top Index ^
Backup  dump-0aj-f/tmp/home0.bak/home make a full backup of the '/home ' directory  dump-1aj-f/tmp/home0.bak/home make an interactive copy of the '/home ' directory Copy  restore-if/tmp/home0.bak restore an interactive backup  rsync-rogpav--delete/home/tmp Both sides of the directory  rsync-rogpav-e SSH--del Ete/home ip_address:/tmp via SSH channel rsync rsync-az-e ssh--delete ip_addr:/home/public/home/local Synchronizing a remote directory to a local directory via SSH and compression  rsync-az-e ssh--delete/home/local ip_addr:/home/public synchronizing the local directory to the remote directory via SSH and compression &NBSP;DD BS =1m If=/dev/hda | gzip | SSH [email protected]_addr ' dd of=hda.gz ' performs a backup of local disk operations on the remote host via SSH  dd IF=/DEV/SDA of=/tmp/file1 backup disk contents to a file  tar-puf Backup.tar/home/user performs an interactive backup operation to the '/home/user ' directory   (cd/tmp/local/&& tar c.) | ssh-c [email protected]_addr ' cd/home/share/&& tar x-p ' copy a directory content from the remote directory via SSH   (tar c/home) | ssh-c [email protected]_addr ' cd/home/backup-home && tar x-p ' copy a local directory in the remote directory via SSH  tar CF-. | (cd/tmp/backup; tar xf-) copy a directory locally to another place, preserving the originalPermissions and links  find/home/user1-name ' *.txt ' | Xargs Cp-av--target-directory=/home/backup/--parents Find and copy all files ending with '. txt ' from one directory to another directory  find/var/log-name ' *.log ' | Tar CV--files-from=-| bzip2 > log.tar.bz2 Find all the files that end with '. Log ' and make a bZIP package  dd If=/dev/hda of=/dev/fd0 bs=512 count=1 do an MBR (Master Boot R Ecord) content copied to floppy disk  dd if=/dev/fd0 Of=/dev/hda bs=512 count=1 recover MBR content from a backup that has been saved to a floppy disk  
Return Top Index ^
Disc cdrecord-v gracetime=2 dev=/dev/cdrom-eject blank=fast-force empty a rewritable disc content Mkisofs/dev/cdrom > Cd.iso Create a disc on disk ISO image File Mkisofs/dev/cdrom | Gzip > Cd_iso.gz Create a compressed disc ISO image file on disk mkisofs-j-allow-leading-dots-r-V "Label CD"-iso-level 4-o./cd.iso data_cd Create an ISO image file for a directory cdrecord-v dev=/dev/cdrom cd.iso burning an ISO image file Gzip-dc cd_iso.gz | Cdrecord Dev=/dev/cdrom-Burn a compressed ISO image file Mount-o loop cd.iso/mnt/iso mount an ISO image file Cd-paranoia-b from one CD to the audio track to the WAV file CD -paranoia--"-3" from a CD to the audio track to the WAV file (parameter-3) Cdrecord--scanbus Scan Bus to identify the SCSI channel DD IF=/DEV/HDC | md5sum Verifying the md5sum encoding of a device, such as a CD
Return Top Index ^
Network-(Ethernet and WiFi wireless)  ifconfig eth0 Displays the configuration of an Ethernet card  ifup eth0 enable a ' eth0 ' network device  ifdown eth0 disable a ' eth0 ' network device  if Config eth0 192.168.1.1 netmask 255.255.255.0 control IP address  ifconfig eth0 promisc set ' eth0 ' into promiscuous mode to sniff packets (sniffing) &NBSP;DHC lient eth0 in DHCP mode enable ' eth0 '  route-n show routing Table route add-net 0/0 GW ip_gateway Configura default Gatew Ay route add-net 192.168.0.0 netmask 255.255.0.0 GW 192.168.1.1 Configure static route to reach network ' 192.168.0.0 /16 '  route del 0/0 GW ip_gateway remove static Route echo "1" >/proc/sys/net/ipv4/ip_forward activate IP rou Ting hostname show hostname of system host www.example.com lookup hostname To resolve name to IP address and VIC Eversa (1)  nslookup www.example.com lookup hostname To resolve name to IP address and viceversa (2)  ip link show s How link status of all Interfaces mii-tool eth0 Show link status of ' eth0 '  ethtool eth0 Show statistics of Netwo RK card ' eth0 '  netstAt-tup Show all active network connections and their PID&NBSP;NETSTAT-TUPL show all network services listening on the SY Stem and their pid tcpdump TCP port show all HTTP traffic iwlist scan show Wireless Networks iwconfig et H1 show configuration of a wireless network Card hostname show hostname host www.example.com lookup hostname to Resolve name to IP address and viceversa nslookup www.example.com lookup hostname To resolve name to IP address and V Iceversa whois www.example.com lookup on whois database 
GO TOP INDEX ^ Microsoft Windows Networks (SAMBA) Nbtscan ip_addr NetBIOS name resolution NMBLOOKUP-A ip_addr NetBIOS Nam E resolution SMBCLIENT-L Ip_addr/hostname Show remote shares of a Windows host SMBGET-RR smb://ip_addr/share like wget c An download files from a host Windows via SMB mount-t smbfs-o username=user,password=pass//winclient/share/mnt/share m Ount a Windows network share

Linux Common Command Daquan

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.