In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "Linux common command collection". In daily operation, I believe many people have doubts about Linux common command collection. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "Linux common command collection". Next, please follow the editor to study!
System information
Processor Architecture of arch display Machine (1)
Processor Architecture of uname-m display Machine (2)
Uname-r shows the kernel version in use
Dmidecode-Q display hardware system components-(SMBIOS / DMI)
Hdparm-I / dev/hda lists the architectural features of a disk
Hdparm-tT / dev/sda performs testable read operations on disk
Cat / proc/cpuinfo displays the information of CPU info
Cat / proc/interrupts display interrupt
Cat / proc/meminfo verifies memory usage
Cat / proc/swaps shows which swap is used
Cat / proc/version shows the kernel version
Cat / proc/net/dev display Network Adapter and Statistics
Cat / proc/mounts displays the loaded file system
Lspci-tv lists PCI devices
Lsusb-tv display USB device
Date displays the system date
Cal 2007 displays the calendar for 2007
Date 041217002007.00 sets the date and time-month, day, hour, year. Second
Clock-w saves time changes to BIOS
Shutdown (shutdown, restart and logout of the system)
Shutdown-h now shuts down the system (1)
Init 0 shuts down the system (2)
Telinit 0 shuts down the system (3)
Shutdown-h hours:minutes & shuts down the system at the scheduled time
Shutdown-c cancels shutting down the system at the scheduled time
Shutdown-r now restart (1)
Reboot restart (2)
Logout logout
Files and directories
Cd / home enter the'/ home' directory'
Cd.. Return to the previous directory
Cd.. /.. Return to the upper two-level directory
Cd enters the personal home directory
Cd ~ user1 enters the personal home directory
Cd-returns the directory where it was last located
Pwd displays the work path
Ls view the files in the directory
Ls-F View the files in the directory
Ls-l displays the details of files and directories
Ls-a shows hidden files
Ls * [0-9] * displays file and directory names that contain numbers
Tree displays the tree structure of files and directories starting 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 called 'dir1''
Mkdir dir1 dir2 creates two directories at the same time
Mkdir-p / tmp/dir1/dir2 create a directory tree
Rm-f file1 deletes a file called 'file1''
Rmdir dir1 deletes a directory called 'dir1''
Rm-rf dir1 deletes a directory called 'dir1' and deletes its contents at the same time
Rm-rf dir1 dir2 deletes both directories and their contents
Mv dir1 new_dir rename / move a directory
Cp file1 file2 copies 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 copy 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 modifies the timestamp of a file or directory-(YYMMDDhhmm)
File file1 outputs the mime type of the file as text
Iconv-l lists known codes
Iconv-f fromEncoding-t toEncoding inputFile > outputFile creates a new from the given input file by assuming it is 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)
File search
Find /-name file1 enters the root file system from'/'to search for files and directories
Find /-user user1 searches for files and directories belonging to user 'user1'
Find / home/user1-name\ * .bin searches for files ending with '.bin' in the directory'/ home/user1''
Find / usr/bin-type f-atime + 100 searches for execution files that have not been used in the past 100 days
Find / usr/bin-type f-mtime-10 searches for files that have been 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 in '.rpm' and ignores removable devices such as CD-ROMs and Agile drives
Locate\ * .ps looks for files that end with '.ps'-run the 'updatedb' command first
Whereis halt shows the location of a binary, source, or man
Which halt displays the full path to a binary or executable file
Mount a file system
Mount / dev/hda2 / mnt/hda2 mount a disk called hda2-make sure the directory'/ mnt/hda2' already exists
Umount / dev/hda2 unmount a disk called hda2-exit from mount point'/ mnt/hda2' first
Fuser-km / mnt/hda2 force uninstall when the device is busy
Umount-n / mnt/hda2 runs the uninstall operation without writing to the / etc/mtab file-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 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 mounts a file or ISO image file
Mount-t vfat / dev/hda5 / mnt/hda5 mounts a Windows FAT32 file system
Mount / dev/sda1 / mnt/usbdisk mounts a usb shortcut or flash memory device
Mount-t smbfs-o username=user,password=pass / / WinClient/share / mnt/share mounts a windows network share
Disk space
Df-h displays a list of mounted partitions
Ls-lSr | more arranges files and directories by size
Du-sh dir1 estimates the directory 'disk space already used by dir1''
Du-sk * | sort-rn displays the size of files and directories in turn based on capacity
Rpm-Q-a-- qf'{SIZE} t% {NAME} n' | sort-K1Power1n displays the space used by installed rpm packages in turn based on size (fedora, redhat systems)
Dpkg-query-W-fallow packages ${Installed-Size;10} t ${Package} n' | sort-K1Magin1n displays the space used by installed deb packages based on size (ubuntu, debian systems)
Users and groups
Groupadd group_name creates a new user group
Groupdel group_name deletes 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 creates a user belonging to the "admin" user group
Useradd user1 creates a new user
Userdel-r user1 deletes a user ('- r 'excludes home directory)
Usermod-c "User FTP"-g system-d / ftp/user1-s / bin/nologin user1 modify user attributes
Passwd change password
Passwd user1 modifies a user's password (only root is allowed to execute)
Chage-E 2005-12-31 user1 sets the expiration period for user passwords
Pwck checks the file format and syntax correction of'/ etc/passwd''as well as the presence of users
Grpck checks the file format and syntax correction of'/ etc/passwd''as well as existing groups
Newgrp group_name logs in to a new group to change the default group of newly created files
Permissions for files-use "+" to set permissions and "-" to cancel
Ls-lh display permissions
Ls / tmp | pr-T5-W$COLUMNS divides the terminal into 5 columns for display
Chmod ugo+rwx directory1 sets permissions for directory owners (u), groups (g), and others (o) to read (r), write (w), and execute (x)
Chmod go-rwx directory1 deletes group (g) and others (o) read and write permissions to the directory
Chown user1 file1 changes the owner property of a file
Chown-R user1 directory1 changes the owner properties of a directory and simultaneously changes the properties of all files in the directory
Chgrp group1 file1 changes the group of files
Chown user1:group1 file1 changes the owner and group properties of a file
Find /-perm-Utility lists all the files in a system that are controlled by SUID
Chmod Utility / bin/file1 sets the SUID bit of a binary file-the user running the file is also given the same permissions as the owner
Chmod Umurs / bin/file1 disables the SUID bit of a binary file
Chmod genders / home/public sets the SGID bit of a directory-similar to SUID, but for directories
Chmod Gmurs / home/public disables the SGID bit of a directory
Chmod STIKY / home/public sets the STIKY bit of a file-only legitimate owners are allowed to delete the file
Chmod Omurt / home/public disables the STIKY bit of a directory
Special properties of the file-use "+" to set permissions, use "-" to cancel
Chattr + a file1 only allows you to read and write files as appends.
Chattr + c file1 allows this file to be automatically compressed / decompressed by the kernel
When chattr + d file1 makes a file system backup, the dump program will ignore this file
Chattr + I file1 is set to an immutable file and cannot be deleted, modified, renamed, or linked
Chattr + s file1 allows a file to be safely deleted
Once the chattr + S file1 application performs a write operation on this file, the system immediately writes the modified result to disk.
Chattr + u file1 if the file is deleted, the system will allow you to restore the deleted file later
Lsattr displays special properties
Package and compress files
Bunzip2 file1.bz2 unzips a file called file1.bz2'
Bzip2 file1 compresses a file called 'file1'
Gunzip file1.gz unzips a file called file1.gz'
Gzip file1 compresses a file called 'file1'
Gzip-9 file1 maximum compression
Rar a file1.rar test_file creates a package called 'file1.rar'
Rar a file1.rar file1 file2 dir1 compresses both 'file1',' file2' and directory 'dir1'
Rar x file1.rar decompress the rar package
Unrar x file1.rar decompress the rar package
Tar-cvf archive.tar file1 creates an uncompressed tarball
Tar-cvf archive.tar file1 file2 dir1 creates an archive file that contains' file1', 'file2' and' dir1'
Tar-tf archive.tar displays the contents of a package
Tar-xvf archive.tar releases a package
Tar-xvf archive.tar-C / tmp releases the package to the / tmp directory
Tar-cvfj archive.tar.bz2 dir1 creates a compressed package in bzip2 format
Tar-xvfj archive.tar.bz2 decompresses a compressed package in bzip2 format
Tar-cvfz archive.tar.gz dir1 creates a compressed package in gzip format
Tar-xvfz archive.tar.gz decompresses a compressed package in gzip format
Zip file1.zip file1 creates a compressed package in zip format
Zip-r file1.zip file1 file2 dir1 compresses several files and directories into a package in zip format at the same time
Unzip file1.zip decompresses a compressed package in zip format
RPM package-(Fedora, Redhat and similar systems)
Rpm-ivh package.rpm installs a rpm package
Rpm-ivh-nodeeps package.rpm installs a rpm package and ignores dependency warnings
Rpm-U package.rpm updates a rpm package without changing its configuration file
Rpm-F package.rpm updates a confirmed installed rpm package
Rpm-e package_name.rpm deletes a rpm package
Rpm-qa displays all installed rpm packages in the system
Rpm-qa | grep httpd displays all rpm packages with the word "httpd" in their names
Rpm-qi package_name gets special information about an installed package
Rpm-qg "System Environment/Daemons" displays the rpm package for a component
Rpm-ql package_name displays a list of files provided by the installed rpm package
Rpm-qc package_name displays a list of configuration files provided by the installed rpm package
Rpm-Q package_name-- whatrequires displays a list of dependencies on a rpm package
Rpm-Q package_name-- whatprovides shows the volume occupied by a rpm packet
Rpm-Q package_name-- scripts displays the script l executed during installation / removal
Rpm-Q package_name-- changelog displays the modification history of a rpm package
Rpm-qf / etc/httpd/conf/httpd.conf confirms which rpm package provided the given file
Rpm-qp package.rpm-l displays a 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 confirms the integrity of a rpm package
Rpm-qa gpg-pubkey confirms the integrity of all installed rpm packages
Rpm-V package_name checks file size, license, type, owner, group, MD5 check and last modification time
Rpm-Va checks all installed rpm packages in the system-use with caution
Rpm-Vp package.rpm confirms that a rpm package is not installed
Rpm2cpio package.rpm | cpio-- extract-- make-directories * bin* runs the executable file from a rpm package
Rpm-ivh / usr/src/redhat/RPMS/ `arch` / package.rpm installs a built package from a rpm source code
Rpmbuild-- rebuild package_name.src.rpm builds a rpm package from a rpm source code
YUM package upgrader-(Fedora, RedHat and similar systems)
Yum install package_name download and install a rpm package
Yum localinstall package_name.rpm will install a rpm package and use your own software repository to solve all dependencies for you
Yum update package_name.rpm updates all installed rpm packages on the current system
Yum update package_name updates a rpm package
Yum remove package_name deletes a rpm package
Yum list lists all packages installed on the current system
Yum search package_name searches rpm repository for software packages
Yum clean packages cleans the rpm cache and deletes downloaded packages
Yum clean headers deletes all header files
Yum clean all deletes 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 removes a deb package from the system
Dpkg-l displays all installed deb packages in the system
Dpkg-l | grep httpd displays all deb packages with the word "httpd" in their names
Dpkg-s package_name gets information about a special package that has been installed in the system
Dpkg-L package_name displays a list of files provided by a deb package that has been installed in the system
Dpkg-contents package.deb displays a list of files provided by a package that has not yet been installed
Dpkg-S / bin/ping confirms which deb package provides the given file
APT software tools (Debian, Ubuntu and similar systems)
Apt-get install package_name install / update a deb package
Apt-cdrom install package_name installs / updates a deb package from CD
Software packages in the apt-get update upgrade list
Apt-get upgrade upgrades all installed software
Apt-get remove package_name removes a deb package from the system
Apt-get check confirms that the dependent software repository is correct
Apt-get clean cleans the cache from the downloaded package
Apt-cache search searched-package returns the name of the package containing the string you want to search for
View the contents of the file
Cat file1 looks forward at the contents of the file from the first byte
Tac file1 starts from the last line to view the contents of a file in reverse
More file1 looks at the contents of a long file
Less file1 is similar to the 'more' command, but it allows the same reverse operation in the file as the forward operation
Head-2 file1 looks at the first two lines of a file
Tail-2 file1 looks at the last two lines of a file
Tail-f / var/log/messages view what has been added to a file in real time
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 merges the detailed description text of a file and writes the introduction to a new file
Cat file1 | command (sed, grep, awk, grep, etc...) > > result.txt merges the detailed description text of a file and writes the introduction to an existing file
Grep Aug / var/log/messages look for the keyword "Aug" in the file'/ var/log/messages'
Grep ^ Aug / var/log/messages look for words starting with "Aug" in the file'/ var/log/messages'
Grep [0-9] / var/log/messages Select all lines that contain numbers in the'/ var/log/messages' file
Grep Aug-R / var/log/* searches for the string "Aug" in the directory'/ var/log' and subsequent directories
Sed's example.txt example.txt 1 / 2 example.txt replace "string1" with "string2" in the example.txt file.
Sed'/ ^ $/ d'example.txt removes all blank lines from the example.txt file
Sed'/ * # / d; / ^ $/ d 'example.txt removes all comments and blank lines from the example.txt file
Echo 'esempio' | tr' [: lower:]'[: upper:] 'merge the contents of the upper and lower cells
Sed-e '1d' result.txt excludes the first line from the file example.txt
Sed-n'/ stringa1/p' view lines that contain only the word "string1"
Sed-e's / * $/ / 'example.txt removes the white space character at the end of each line
Sed-e's example.txt Stringa1 example.txt removes only the word "string1" from the document and retains the rest
Sed-n'1 example.txt 5pbot 5q' view the content from line 1 to line 5
Sed-n'5p * 5q' example.txt view line 5
Sed-e's example.txt replace multiple zeros with a single zero
The number of lines in the cat-n file1 marking file
Cat example.txt | awk 'NR%2==1' deletes all even lines in the example.txt file
Echo a b c | awk'{print $1} 'view the first column of a row
Echo a b c | awk'{print $1 and 3} 'view the first and third columns of a row
Paste file1 file2 merges the contents of two files or columns
Paste-d'+ 'file1 file2 merges the contents of two files or columns, distinguished by "+" in the middle
Sort file1 file2 sorts the contents of two files
Sort file1 file2 | uniq fetches the union of two files (only one copy of duplicate lines is retained)
Sort file1 file2 | uniq-u delete the intersection and leave other lines
Sort file1 file2 | uniq-d takes out the intersection of two files (leaving only files that exist in both files)
Comm-1 file1 file2 compares the contents of two files and deletes only the contents contained in 'file1'
Comm-2 file1 file2 compares the contents of the two files and deletes only the contents contained in 'file2'
Comm-3 file1 file2 compares the contents of two files and deletes only the common parts of the two files
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 displays all allowed conversion formats
File system analysis
Badblocks-v / dev/hda1 checks 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 hda1 disk
E2fsck / dev/hda1 repair / check the integrity of the ext2 file system on hda1 disk
E2fsck-j / dev/hda1 repair / check the integrity of the ext3 file system on hda1 disk
Fsck.ext3 / dev/hda1 repair / check the integrity of the ext3 file system on hda1 disk
Fsck.vfat / dev/hda1 repair / check the integrity of the fat file system on hda1 disk
Fsck.msdos / dev/hda1 repair / check the integrity of the dos file system on hda1 disk
Dosfsck / dev/hda1 repair / check the integrity of the dos file system on hda1 disk
Initialize a file system
Mkfs / dev/hda1 creates a file system in the hda1 partition
Mke2fs / dev/hda1 creates a linux ext2 file system in the hda1 partition
Mke2fs-j / dev/hda1 creates a linux ext3 (journal) 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 creates a swap file system
SWAP file system
Mkswap / dev/hda3 creates a swap file system
Swapon / dev/hda3 enables a new swap file system
Swapon / dev/hda2 / dev/hdb3 enables two swap partitions
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 backup of the'/ home' directory
Restore-if / tmp/home0.bak restore an interactive backup
Rsync-rogpav-- delete / home / tmp synchronizes directories on both sides
Rsync-rogpav-e ssh-- delete / home ip_address:/tmp through SSH channel rsync
Rsync-az-e ssh-- delete ip_addr:/home/public / home/local synchronizes a remote directory to a local directory through ssh and compression
Rsync-az-e ssh-- delete / home/local ip_addr:/home/public synchronizes the local directory to the remote directory through ssh and compression
Dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr'dd of=hda.gz' performs a backup of the local disk on the remote host through ssh
Dd if=/dev/sda of=/tmp/file1 backs up the 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 user@ip_addr'cd / home/share/ & & tar x-p 'copy the contents of a directory in a remote directory through ssh
(tar c / home) | ssh-C user@ip_addr'cd / home/backup-home & & tar x-p 'copy a local directory in the remote directory through ssh
Tar cf -. | | (cd / tmp/backup; tar xf -) locally copy a directory to another place, retaining the original permissions and links |
Find / home/user1-name'* .txt'| xargs cp-av-- target-directory=/home/backup/-- parents finds and copies all files ending in '.txt' from one directory to another directory
Find / var/log-name'* .log'| tar cv-- files-from=- | bzip2 > log.tar.bz2 finds all files ending in '.log' and makes them into a bzip package
Dd if=/dev/hda of=/dev/fd0 bs=512 count=1 makes an action to copy the MBR (Master Boot Record) content to the floppy disk.
Dd if=/dev/fd0 of=/dev/hda bs=512 count=1 restores MBR content from a backup that has been saved to a floppy disk
Optical disk
Cdrecord-v gracetime=2 dev=/dev/cdrom-eject blank=fast-force clear the contents of a rewritable disc
Mkisofs / dev/cdrom > cd.iso creates an iso image of the CD on disk
Mkisofs / dev/cdrom | gzip > cd_iso.gz creates a compressed CD-iso image file on disk
Mkisofs-J-allow-leading-dots-R-V "Label CD"-iso-level 4-o. / cd.iso data_cd create a directory iso image file
Cdrecord-v dev=/dev/cdrom cd.iso burns an ISO image file
Gzip-dc cd_iso.gz | cdrecord dev=/dev/cdrom-Burns a compressed ISO image file
Mount-o loop cd.iso / mnt/iso mounts an ISO image file
Cd-paranoia-B transcribes audio tracks from a CD CD to a wav file.
Cd-paranoia-- "- 3" transcribed audio tracks from a CD CD to wav files (parameter-3)
Cdrecord-scanbus scan bus to identify scsi channels
Dd if=/dev/hdc | md5sum verifies the md5sum code of a device, such as a CD
Network-(Ethernet and WIFI Wireless)
Ifconfig eth0 displays the configuration of an Ethernet card
Ifup eth0 enables a 'eth0' network device
Ifdown eth0 disables a 'eth0' network device
Ifconfig eth0 192.168.1.1 netmask 255.255.255.0 Control IP address
Ifconfig eth0 promisc sets' eth0' to promiscuous mode to sniff packets (sniffing)
Dhclient eth0 enables' eth0' in dhcp mode
Route-n show routing table
Route add-net 0 Universe 0 gw IP_Gateway configura default gateway
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.0Accord 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.example.com lookup hostname to resolve name to ip address and viceversa (1)
Nslookup www.example.com lookup hostname to resolve name to ip address and viceversa (2)
Ip link show 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 and their PID
Tcpdump tcp port 80 show all HTTP traffic
Iwlist scan show wireless networks
Iwconfig eth2 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 viceversa
Whois www.example.com lookup on Whois database
Microsoft Windows networks (SAMBA)
Nbtscan ip_addr netbios name resolution
Nmblookup-An ip_addr netbios name resolution
Smbclient-L ip_addr/hostname show remote shares of a windows host
Smbget-Rr smb://ip_addr/share like wget can download files from a host windows via smb
Mount-t smbfs-o username=user,password=pass / / WinClient/share / mnt/share mount a windows network share
At this point, the study of "Linux common command collection" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.