File and directory cd/home enter/home directory cd .. back to the upper-level directory cd... back to the upper-level directory cd .. back to the upper-level directory cd ~ User1 go to my home directory cd-return to the last Directory pwd display working path ls view files in the directory ls-F View files in the directory ls-l display files and directories Files and directories
Cd/home to the '/home' Directory'
Cd .. back to the upper-level Directory
Cd... returns the last two levels of directories.
Cd to enter your home directory
Cd ~ User1: enter the personal home directory
Cd-return the last Directory
Pwd display working path
Ls to view files in the directory
Ls-F: View files in the directory
Ls-l displays detailed information about files and directories
Ls-a: show hidden files
Ls * [0-9] * displays the file name and directory name containing numbers
Tree: tree structure in which files and directories start from the root directory (1)
Lstree displays the tree structure of files and directories starting from the root directory (2)
Mkdir dir1 creates a directory named 'dir1'
Mkdir dir1 dir2 creates two directories at the same time
Mkdir-p/tmp/dir1/dir2 create a directory tree
Rm-f file1: delete a file named 'file1'
Rmdir dir1 deletes a directory named 'dir1'
Rm-rf dir1: Delete a directory named 'dir1' and delete its contents at the same time.
Rm-rf dir1 dir2 simultaneously deletes two directories and their contents
Mv dir1 new_dir rename/move a directory
Cp file1 file2 copy a file
Cp dir/*. copy all files in a directory to the current working directory.
Cp-a/tmp/dir1. copy a directory to the current working directory.
Cp-a dir1 dir2 copies a directory
Ln-s file1 lnk1 creates a soft link to a file or directory
Ln file1 lnk1 creates 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
Iconv-l list known codes
Iconv-f fromEncoding-t toEncoding inputFile> outputFilecreates a new from the given input file by assuming itis encoded in fromEncoding and converting it totoEncoding.
Find. -maxdepth 1-name *. jpg-print-exec convert "{}"-resize80x60 "thumbs/{}" \; batch resize files in the currentdirectory and send them to a thumbnails directory (requires convert from Imagemagick)
File Search
Find/-name file1 start from '/' and enter the root file system to search for files and directories.
Find/-user user1 search for files and directories belonging to user 'user1'
Find/home/user1-name \ *. bin search for files with the end of '. bin' in the'/home/user1' Directory
Find/usr/bin-type f-atime + 100 search for execution files that have not been used in the past 100 days
Find/usr/bin-type f-mtime-10 search for files 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 searches for files ending with '. rpm', ignoring drive drives, disks, and other removable devices.
Locate \ *. ps search for files ending with '. Ps'-run the 'updatedb' command first.
Whereis halt displays the location of a binary file, source code, or man
Which halt displays the complete path of a binary or executable file
Mount a file system
Mount/dev/hda2/mnt/hda2 mount a disk named hda2-confirm the directory '/mnt/hda2' already exists
Umount/dev/hda2 detach a disk named hda2-first exit from the Mount point '/mnt/hda2'
Fuser-km/mnt/hda2 force uninstall when the device is busy
Umount-n/mnt/hda2 run the unmount operation without writing the/etc/mtab File-This operation is useful when the file is read-only or when the disk is full
Mount/dev/fd0/mnt/floppy mount a floppy disk
Mount/dev/cdrom/mnt/cdrom to mount a cdrom or dvdrom.
Mount/dev/hdc/mnt/cdrecorder to mount a cdrw or dvdrom
Mount/dev/hdb/mnt/cdrecorder to 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/usb disk mount a usb disk or flash memory device
Mount-t smbfs-o username = user, password = pass // WinClient/share/mnt/share mount a windows network share
Disk space
Df-h: List of mounted partitions
Ls-lSr | more: arrange files and directories in size
Du-sh dir1 estimation directory 'dir1' used disk space'
Du-sk * | sort-rn displays the size of files and directories in sequence based on the capacity.
Rpm-q-a -- qf' % 10 {SIZE} t % {NAME} n' | sort-k1, 1n displays the space used by the installed rpm Package (fedora, redhat system) in sequence based on the size of the package)
Dpkg-query-W-f = '$ {Installed-Size; 10} t $ {Package} n' | sort-k1, 1n displays the space used by the installed deb package (ubuntu, debian) based on the size of the package)
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/bashuser1 create a user belonging to the "admin" user group
Useradd user1 create a new user
Userdel-r user1 delete a user ('-R' exclude the main directory)
Usermod-c "User FTP"-g system-d/ftp/user1-s/bin/nologin user1 modify User attributes
Passwd change password
Passwd user1: modify the password of a user (only root is allowed)
Chage-E 2005-12-31 user1 set the expiration time of the user password
Pwck checks the file format and syntax of '/etc/passwd' and the existing users.
Grpck checks '/etc/passwd' file format and syntax correction and existing groups
Newgrp group_name log in to a new group to change the default group of the newly created File
File permissions-use "+" to set permissions, use "-" to cancel
Ls-lh display permission
Ls/tmp | pr-T5-W $ COLUMNS divides the terminal into 5 COLUMNS for display
Chmod ugo + rwx directory1 sets the permission of the Directory owner (u), group (g), and others (o) to read (r), write (w), and execute (x ).
Chmod go-rwx directory1 delete the group (g) and others (o) to read and write the directory.
Chown user1 file1 changes the attributes of all users in a file.
Chown-R user1 directory1 changes the attributes of all objects in a directory and
Chgrp group1 file1 changes the file Group
Chown user1: group1 file1 changes the owner and group attributes of a file.
Find/-perm-u + s lists all files in the system that use SUID control.
Chmod u + s/bin/file1 sets the SUID bit of a binary file. the user running the file is also granted the same permissions as the owner.
Chmod u-s/bin/file1 disable the SUID bit of a binary file
Chmod g + s/home/public sets the SGID bit of a directory-similar to SUID, but this is for the Directory
Chmod g-s/home/public disables the SGID bit of a directory
Chmod o + t/home/public set the STIKY bit of an object-only allow the legal owner to delete the object
Chmod o-t/home/public disable the STIKY bit of a directory
Special properties of the file-use "+" to set permissions, use "-" to cancel
Chattr + a file1 can only read and write files in append mode
Chattr + c file1 allows the file to be automatically compressed/decompressed by the kernel
When the chattr + d file1 file system is backed up, the dump program will ignore this file
Chattr + I file1 is set to an unchangeable file and cannot be deleted, modified, renamed, or linked.
Chattr + s file1 allows a file to be safely deleted
Chattr + S file1 once the application writes the file, the system immediately writes the modification result to the disk.
Chattr + u file1 if the file is deleted, the system will allow you to restore the deleted file in the future.
Lsattr displays special properties
Package and compress files
Bunzip2 file1.bz2 decompress a file named 'file1.bz2'
Bzip2 file1: compress a file named 'file1 '.
Gunzip file1.gz decompress a file named 'file1.gz'
Gzip file1: compress a file named 'file1'
Gzip-9 file1 maximum compression
Rar a file1.rar test_file create a package named 'file1.rar'
Rar a file1.rar file1 file2 dir1 simultaneously compresses 'file1', 'file2', and the Directory 'dir1'
Rar x file1.rar unzip the rar package
Unrar x file1.rar unzip the rar package
Tar-cvf archive.tar file1 create a non-compressed tarball
Tar-cvf archive.tar file1 file2 dir1 creates an archive file containing 'file1', 'file2', and 'dir1'
Tar-tf archive.tar displays the content in a package
Tar-xvf archive.tar release a package
Tar-xvf archive.tar-C/tmp release the compressed package to the/tmp directory.
Tar-cvfj archive.tar.bz2 dir1 create a compressed package in bzip2 format
Tar-xvfj archive.tar.bz2 extract a compressed package in bzip2 format
Tar-cvfz archive.tar.gz dir1 create a gzip compressed package
Tar-xvfz archive.tar.gz unzip a gzip compressed package
Zip file1.zip file1 create a zip package
Zip-r file1.zip file1 file2 dir1 compresses several files and directories into a zip package at the same time
Unzip file1.zip decompress a zip package
RPM Package-(Fedora, Redhat and similar systems)
Rpm-ivh package. rpm install an rpm package
Rpm-ivh -- nodeeps package. rpm installs an rpm package and ignores dependency warnings.
Rpm-U package. rpm updates an rpm package but does not change its configuration file
Rpm-F package. rpm updates an rpm package that has been installed.
Rpm-e package_name.rpm delete an rpm Package
Rpm-qa: displays all installed rpm packages in the system
Rpm-qa | grep httpd: displays all rpm packages whose names contain the words "httpd ".
Rpm-qi package_name: obtains special information about an installed package.
Rpm-qg "System Environment/Daemons" displays the rpm package of a component
Rpm-ql package_name: displays the list of files provided by an installed rpm package.
Rpm-qc package_name: displays the list of configuration files provided by an installed rpm package.
Rpm-q package_name -- whatrequires: displays a list of dependencies with an rpm package.
Rpm-q package_name -- whatprovides displays the volume of an rpm Package
Rpm-q package_name -- scripts displays the script executed during installation/deletion l
Rpm-q package_name -- changelog displays the modification history of an rpm package.
Rpm-qf/etc/httpd/conf/httpd. conf: confirm which rpm package provides the file.
Rpm-qp package. rpm-l displays the list of files provided by an uninstalled rpm package
Rpm -- import/media/cdrom/RPM-GPG-KEY import public key digital certificate
Rpm -- checksig package. rpm verify the integrity of an rpm package
Rpm-qa gpg-pubkey verify the integrity of all installed rpm packages
Rpm-V package_name check file size, license, type, owner, group, MD5 check, and last modification time
Rpm-Va check all installed rpm packages in the system-use with caution
Rpm-Vp package. rpm confirm that an rpm package is not installed
Rpm2cpio package. rpm | cpio -- extract -- make-directories * bin * run executable files from an rpm package
Rpm-ivh/usr/src/redhat/RPMS/'arch '/package. rpm install a build package from an rpm source code
Rpmbuild -- rebuild package_name.src.rpm build an rpm package from an rpm source code
YUM package installer-(Fedora, RedHat and similar systems)
Yum install package_name download and install an rpm Package
Yum localinstall package_name.rpm will install an rpm Package and use your own software repository to resolve all dependencies for you.
Yum update package_name.rpm update all installed rpm packages in the current system
Yum update package_name update an rpm Package
Yum remove package_name delete an rpm Package
Yum list lists all packages installed in the current system
Yum search package_name search for software packages in the rpm repository
Yum clean packages clear rpm cache delete downloaded package
Yum clean headers delete all header files
Yum clean all delete all cached packages and header files
DEB package (Debian, Ubuntu, and similar systems)
Dpkg-I package. deb install/update a deb package
Dpkg-r package_name: Delete a deb package from the system
Dpkg-l show all deb packages installed in the system
Dpkg-l | grep httpd: displays all deb packages whose names contain the words "httpd ".
Dpkg-s package_name to obtain information about a special package installed in the system
Dpkg-L package_name: displays the list of files provided by a deb package installed in the system
Dpkg -- contents package. deb displays the list of files provided by a package that has not been installed
Dpkg-S/bin/ping to confirm which deb package provides the file
APT software tools (Debian, Ubuntu, and similar systems)
Apt-get install package_name install/update a deb package
Apt-cdrom install package_name install/update a deb package from the CD
Packages in the apt-get update List
Apt-get upgrade all installed software
Apt-get remove package_name delete a deb package from the system
Apt-get check: check that the dependent software warehouse is correct
Apt-get clean clear the cache from the downloaded software package
Apt-cache search searched-package returns the package name containing the string to be searched.
View file content
Cat file1 views the file content forward from the first byte
Tac file1 reversely views the content of a file from the last row.
More file1 view the content of a long file
Less file1 is similar to the 'more' command, but it allows reverse operations like forward operations in the file.
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: view the content added to a file in real time
Text processing
Cat file1 file2... | command <> file?in.txt_or_file=out.txt general syntax for textmanipulation using PIPE, STDIN and STDOUT
Cat file1 | command (sed, grep, awk, grep, etc...)> result.txt combines detailed instructions of a file and writes the introduction to a new file.
Cat file1 | command (sed, grep, awk, grep, etc...)> result.txt combines detailed instructions of a file and writes the introduction to an existing file.
Grep Aug/var/log/messages search for the keyword "Aug" in the '/var/log/messages' file"
Grep ^ Aug/var/log/messages search for words starting with "Aug" in the '/var/log/messages' file
Grep [0-9]/var/log/messages select all rows containing numbers in the '/var/log/messages' file
Grep Aug-R/var/log/* search for the "Aug" string in the '/var/log' directory and the subsequent directory"
Sed's/stringa1/stringa2/g' server110.txt replace "string1" in server110.txt with "string2"
Sed '/^ $/d' server110.txt removes all blank lines from the server110.txt file
Sed '/* #/d;/^ $/d' server110.txt delete all comments and blank lines from the server110.txt file
Echo 'empio' | tr' [: lower:] '[: upper:]' merge the content of upper and lower cells.
Sed-e '1D 'result.txt exclude the first line from the file server110.txt
Sed-n'/stringa1/p' to view rows containing only the word "string1"
Sed-e's/* $ // 'server110.txt delete the last white space character of each line
Sed-e's/stringa1 // g' server110.txt delete the word "string1" from the document and keep all remaining words
Sed-n '1, 5 p; 5q' server110.txt
Sed-n '5 p; 5q' server110.txt view 5th rows
Sed-e's/00 */0/g' server110.txt replace multiple zeros with one zero
Cat-n file1 indicates the number of objects
Cat server110.txt | awk 'NR % 2 = 1' delete all even rows in the server110.txt file
Echo a B c | awk '{print $1 }'
Echo a B c | awk '{print $1, $3}' view the first and third columns of a row
Paste file1 file2 combines two files or two columns
Paste-d '+ 'file1 file2 combines the content of two files or two columns, which are separated by "+"
Sort file1 file2 sorts the content of two files
Sort file1 file2 | uniq extracts the union of the two files (duplicate rows are retained for only one copy)
Sort file1 file2 | uniq-u delete the intersection and leave other rows
Sort file1 file2 | uniq-d extracts the intersection of the two files (only files that exist in both files are left)
Comm-1 file1 file2: compare the content of the two files to delete only the content contained in 'file1'
Comm-2 file1 file2: compare the two files to delete only the content contained in 'file2 '.
Comm-3 file1 file2: the contents of the two files are only deleted.
Character setting and file format conversion
Dos2unix filedos.txt fileunix.txt converts the format of a text file from MSDOS to UNIX
Unix2dos fileunix.txt filedos.txt converts the format of a text file from UNIX to MSDOS
Recode.. HTML <page.txt> page.html converts a text file to html
Recode-l | more: Display All allowed conversion formats
File system analysis
Badblocks-v/dev/hda1 check bad magnetic blocks on disk hda1
Fsck/dev/hda1 repair/check linux file system integrity 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 the integrity of the ext2 file system on the hda1 disk
E2fsck-j/dev/hda1 repair/check the integrity of the ext3 file system on the hda1 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
Initialize a file system
Mkfs/dev/hda1 create a file system in the hda1 partition
Mke2fs/dev/hda1 create a linux ext2 file system in the hda1 partition
Mke2fs-j/dev/hda1 create a linux ext3 (log-type) file system in the hda1 partition
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
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
Backup
Dump-0aj-f/tmp/home0.bak/home to create a full backup of the '/home' Directory
Dump-1aj-f/tmp/home0.bak/home to create an interactive backup in the '/home' Directory
Restore-if/tmp/home0.bak restore an interactive backup
Rsync-rogpav -- delete/home/tmp synchronize directories on both sides
Rsync-rogpav-e ssh -- delete/home ip_address:/tmp rsync through the SSH channel
Rsync-az-e ssh -- delete ip_addr:/home/public/home/local synchronize a remote directory to a local directory through ssh and compression
Rsync-az-e ssh -- delete/home/local ip_addr:/home/public synchronize local directories to remote directories through ssh and compression
Dd bs = 1 M if =/dev/hda | gzip | ssh user @ ip_addr 'DD of1_hda.gz 'back up the local disk using ssh on the remote host
Dd if =/dev/sda of =/tmp/file1 back up disk content to a file
Tar-Puf backup.tar/home/user performs an interactive backup operation on the '/home/user' directory.
(Cd/tmp/local/& tar c .) | ssh-C user @ ip_addr 'CD/home/share/& tar x-p' copy a directory content in the remote directory through ssh
(Tar c/home) | ssh-C user @ ip_addr 'CD/home/backup-home & tar x-p' copy a local directory through ssh in the remote directory
Tar cf-. | (cd/tmp/backup; tar xf-) copy a local directory to another location, retain original permissions and links
Find/home/user1-name '*. txt '| xargs cp-av -- target-directory =/home/backup/-- parents searches for and copies all files ending with '.txt' from one directory to another.
Find/var/log-name '*. log' | tar cv -- files-from =-| bzip2> log.tar.bz2 search for all files ending with'. Log' and create a bzip package
Dd if =/dev/hda of =/dev/fd0 bs = 512 count = 1 copy the MBR (Master BootRecord) content to a floppy disk.
Dd if =/dev/fd0 of =/dev/hda bs = 512 count = 1 recover MBR content from the backup that has been saved to the floppy disk
CD
Cdrecord-v gracetime = 2 dev =/dev/cdrom-eject blank = fast-force clear a rewritable CD content
Mkisofs/dev/cdrom> cd. iso create an iso image file for the cd on the disk.
Mkisofs/dev/cdrom | gzip> cd_iso.gz create a compressed CD iso image file on the disk
Mkisofs-J-allow-leading-dots-R-V "Label CD"-iso-level 4-o./cd. iso data_cd
Cdrecord-v dev =/dev/cdrom cd. iso burn 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 transfers audio streams from a CD disc to a wav file
Cd-paranoia -- "-3" transfers audio streams from a CD disc to a wav file (parameter-3)
Cdrecord-scanbus scans the bus to identify scsi channels
Dd if =/dev/hdc | md5sum verifies the md5sum code of a device, for example, a CD
Network-(Ethernet and Wi-Fi)
Ifconfig eth0 displays the configuration of an Ethernet card
Ifup eth0 enables an 'eth0' network device
Ifdown eth0 disable a 'eth0' network device
Ifconfig eth0 192.168.1.1 netmask 255.255.255.0 control IP address
Ifconfig eth0 promisc sets 'eth0' to hybrid mode to sniff packets (sniffing)
Dhclient eth0 is enabled in dhcp mode 'eth0'
Route-n show routing table
Route add-net 0/0 gw IP_Gateway configura default gateway
Route add-net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1configure 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 routing
Hostname show hostname of system
Host www.server110.com lookup hostname to resolve name to ipaddress and viceversa (1)
Nslookup www.server110.com lookup hostname to resolve name to ipaddress and viceversa (2)
Ip link show link status of all interfaces
Mii-tool eth0 show link status of 'eth0'
Ethtool eth0 show statistics of network card 'eth0'
Netstat-tup show all active network connections and their PID
Netstat-tupl show all network services listening on the system andtheir PID
TcpdumpTcp port 80 show all HTTP traffic
Iwlist scan show wireless networks
Iwconfig eth1 show configuration of a wireless network card
Hostname show hostname
Host www.server110.com lookup hostname to resolve name to ipaddress and viceversa
Nslookup www.server110.com lookup hostname to resolve name to ipaddress and viceversa
Whois www.server110.com lookup on Whois database
Go top index ^
Microsoft Windows networks (SAMBA)
Nbtscan ip_addr netbios name resolution
Nmblookup-A ip_addr netbios name resolution
Smbclient-L ip_addr/hostname show remote shares of a windowshost
Smbget-Rr smb: // ip_addr/share like wget can download files from ahost windows via smb
Mount-t smbfs-o username = user, password = pass // WinClient/share/mnt/share mount a windows network share
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