preface
The latest statistics show that Linux adoption is growing at a very rapid rate, with Linux steadily gaining market share over the past few years and gaining significantly in 2020, setting a new record in this regard in May.
Advantages of Linux:
- Linux doesn’t need to choose whether to put the software on drive C or drive D, it already defines which files go where
- You don’t need anti-virus software
- No need to clean up the trash
- There is no need to free memory
- There’s no activation required, it’s open source and free
- No disk optimization is required
- And no annoying popovers
- There are no mandatory updates
Linux Study Manual covers: Common commands, disk management, user management, file permissions, and directory structure, software installation, time management, start the boot and run level, process management, resources monitoring, system services, environmental management, network management, configuration file, project tasks, VI/VIM editor, compression, packaging, performance optimization, faqs, a friend in needClick here toHope it was helpful
View the Linux system information
Arch # Displays the processor architecture of the machine (1) UName -m # Displays the processor architecture of the machine (2) uname -r # displays the kernel version in use dMIDecode -q # displays the hardware system components - (SMBIOS/DMI) hdPARm -I Hdparm-tt /dev/sda # Perform a test read on the disk cat /proc/cpuinfo # Display CPU info cat /proc/interrupts # Display interrupt cat /proc/meminfo # use cat /proc/swaps # show which swaps were used cat /proc/version # Show kernel version cat /proc/net/dev # Show network adapter and statistics cat Mounts /proc/mounts # Displays loaded file systems lSPci-tv # displays PCIE devices lsusB-tv # displays USB devicesCopy the code
Date Displays the system date
CAL 2007 # display calendar for 2007 date 041217002007.00 # set date and time - month/day/year. Seconds clock -w # Saves time changes to BIOSCopy the code
Shutdown (shutdown, restart, logout)
Shutdown -h hours:minutes & # Shutdown -c Shutdown -r now # restart (1) reboot # Logout # LogoutCopy the code
Files and Directories
CD /home # Go to '/ home' directory 'CD.. # return to the directory CD.. /.. CD ~user1 # go to your home directory CD - # Go to your home directory PWD # Show the working path ls # View the files in the directory ls -f # View the files in the directory ls -l # Show the details of the files and directories Ls -a # show hidden files ls *[0-9]* # show file names and directory names containing numbers tree # show files and directories from the root tree (1) lstree # Show files and directories from the root tree (2) mkdir dir1 # create a file called Mkdir -p/TMP /dir1/dir2 # Create a directory tree rm -f file1 # Delete a file called 'file1' 'rmdir dir1 Rm -rf dir1 dir2 # Delete both directories and their contents mv dir1 new_dir # rename/move a directory # 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 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 Filee1 outputs the mime type of the file as text iconv -l # 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)Copy the code
File search
Find / -user user1 # Search for files and directories belonging to user 'user1' find /home/user1-name \*.bin # in directory Find /usr/bin-type f-atime +100 # Find /usr/bin-type f-mtime that has not been used in the past 100 days Find / -name \*. RPM -exec chmod 755 '{}' \; Find / -xdev -name \*.rpm # find / -xdev -name \*.rpm # find / -xdev -name \*.rpm Ps # Locate a file ending in '. Ps' - first run the 'updatedb' command whereis halt # display a binary file, source code, or the location of man which halt Display the full path to a binary or executable fileCopy the code
Mount a file system
Mount /dev/hda2 / MNT /hda2 # mount a disk named hda2 - make sure the directory '/ MNT /hda2' already exists Umount -n/MNT /hda2 # Run the unmount 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 cdrom/dvdrom /dev/hdc/MNT/cdRecorder # Mount Cdrom/dvdrom /dev/hdc/MNT/cdRecorder # Mount Cdrom/dvdrom /dev/hdc/MNT/cdRecorder /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 flash drive/SMBFS -o //WinClient/share/MNT /shareCopy the code
Disk space dependence
Df -h # show has mounted partition list ls - lSr | more # arranged in size file and directory du - sh # dir1-name estimate directory 'dir1-name' have to use the disk space 'du - sk * | sort - rn # based on SIZE, in turn, according to the SIZE of the files and directories RPM - q - a - qf '10 {NAME} {SIZE} t % % n' | sort - k1, 1 n # based on the SIZE of the display has been installed in turn the space used by RPM package (fedora, Dpkg-query-w-f ='${installed-size; 10} ${Package} n 't | sort - k1, 1 n # based on size display installed deb Package used by space (ubuntu, debian system)Copy the code
Users and Groups
Groupadd group_name # Create a 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 'admin' useradd user1 # create a user belonging to 'admin' userdel -r User1 # Delete a User ('-r' exclude home directory) usermod -c "User FTP" -g system -d/FTP /user1 -s /bin/nologin user1 # Modify User attributes passwd # modify password Chage -e 2005-12-31 user1 # Set password expiry PWCK # Check '/etc/passwd' file format and syntax correction and existing user Newgrp group_name # Log in to a new group to change the default group for the newly created fileCopy the code
File permissions
Use "+" to set permissions, The use of "-" is used to cancel the ls - lh # show permissions ls/TMP | pr - T5 - # W $COLUMNS will be divided into terminal 5 bar shows chmod ugo + RWX directory1 # set directory of all the people (u), group (g) and others (o) to read (r ), write (w), and execute (x) permissions chmod go-rwx directory1 # Delete group (g) and others (O) 's read and write execute permissions chown user1 file1 # change the owner attribute of a file chown -r user1 Directory1 # Change the owner properties of a directory and change the properties of all files in the directory CHGRP group1 file1 # Change the group chown user1:group1 file1 # Change the owner and group properties of a file find / Chmod u+s /bin/file1 # Set 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 Chmod g+s /home/public # set a directory's SGID bit - similar to SUID, Chmod g-s /home/public # Disable the SGID bit of a directory chmod o+t /home/public # Set the STIKY bit of a file - only allow valid owners to delete files chmod o-t /home/public # Disable STIKY bits for a directoryCopy the code
Special properties of the file
Chattr +c file1 # Allows this file to be automatically compressed/uncompressed by the kernel. Chattr +d file1 # Dump ignores chattr + I file1 # as immutable, Cannot be deleted, modified, renamed, or linked chattr +s file1 # Allows a file to be safely deleted once an application has written to the file. Chattr +u file1 # If a file is deleted, the system will allow you to restore the deleted file laterCopy the code
Package and compress files
Bz2 # unzip a file called 'file1.bz2' bzip2 file1 # unzip a file called 'file1.bz2' gunzip file1.gz # Unzip a file called 'file1.gz' gzip Gzip -9 file1 # maximum compression rar a file1.rar test_file # Create a package called 'file1.rar' rar a file1.rar file1 File2 dir1 # compress 'file1', Rar # Decompress rar package tar -cvf archive.tar file1 # Create an uncompressed tarball tar -cvf archive.tar file1 file2 dir1 # create a file containing 'file1', Tar # Display the contents of a package tar -xvf archive.tar # Release a package tar -xvf archive.tar -c/TMP / TMP tar -cvfj archive.tar.bz2 dir1 # create a bzip2 package tar -jxvf archive.tar.bz2 # decompress a bzip2 package tar -cvfz Gz dir1 # Create a gzip package tar -zxvf archive.tar.gz # extract a gzip package zip 1.zip file1 # create a zip package zip -r Zip file1 file2 dir1 # Decompress several files and directories into a zip package. Unzip file1.zip # Decompress a zip packageCopy the code
RPM packages (Fedora, Redhat, and similar systems)
RPM RPM -ivh --nodeeps package. RPM # Install an RPM package and ignore dependency warnings RPM -u package. RPM # Update an RPM package without changing its configuration file RPM - F package. The RPM # update a sure you have installed the RPM package RPM -e package_name. RPM qa # # to delete a RPM package RPM - list all installed in the system of RPM package RPM - qa | grep HTTPD RPM -qg "System Environment/Daemons" # RPM -ql # RPM -qg "System Environment/Daemons" # RPM -qg RPM -q package_name --whatrequires RPM -q package_name --whatrequires RPM -q package_name --whatprovides # Display the volume of an RPM package RPM -q package_name --scripts # Display the scripts executed during installation/deletion Package_name RPM - q - changelog # show a RPM package revision history RPM - qf/etc/HTTPD/conf/HTTPD. Conf # the confirmation to the file which RPM - RPM package provided by the qp package. The RPM -l # Display the list of files provided by an RPM package that has not been installed RPM --import /media/cdrom/RPM -gpg-key # Import the public KEY digital certificate RPM --checksig package. RPM # Verify the integrity of an RPM package RPM -qa gpg-pubkey # Check the integrity of all installed RPM packages RPM -v package_name # Check the file size, license, type, owner, group, MD5 check, and last modified time RPM -va # Check all installed RPM packages in the system - Use with caution RPM - Vp package. RPM # to confirm a RPM package has not been installed rpm2cpio package. The RPM | cpio, extract, the make - bin directories * * # from a RPM package run RPM for executable files Rpmbuild --rebuild package_name.src. RPM -- install package_name.src. RPM -- install package_name.src. RPM The RPM packageCopy the code
YUM (Fedora, RedHat and similar systems)
# yum install package_name # yum install package_name # yum install package_name # yum install package_name # yum install package_name # Yum update package_name # yum update package_name # yum update package_name # yum remove # yum search package_name # yum clean packages # yum clean packages # yum search package_name # yum clean packages # yum clean packages # Yum Clean all # yum clean all # delete all cached packages and headersCopy the code
DEB packages (Debian, Ubuntu, and similar systems)
DPKG -i package. Deb # install/update a deb package DPKG -r package_name # deleted from the system a deb package DPKG -- l # list all installed in the system of deb package DPKG -l | grep HTTPD DPKG -l package_name # displays a list of files DPKG has been installed in your system DKG -s /bin/ping DKG -s /bin/ping DKG -s /bin/pingCopy the code
APT software tools (Debian, Ubuntu and similar systems)
Apt-cdrom install package_name apt-cdrom install package_name Apt-get install package apt-get install package apt-get install package apt-get install package apt-get install package apt-get Searched-searched-package returns the name of the package containing the searched stringCopy the code
Viewing file Contents
Cat file1 # Forward view the contents of a file from the first byte tac file1 # Reverse view the contents of a file from the last line more file1 # View the contents of a long file less file1 # Similar to 'more', But it allows the same reverse operation in a file as the forward operation 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 contents added to a file in real timeCopy the code
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 a text file detailed instructions, and during the introduction to writing a new file cat file1 | command (sed, grep, awk, grep, etc...). >> result. TXT # merge a file's verbose text, Grep ^Aug /var/log/messages # Grep Aug /var/log/messages # Grep ^Aug /var/log/messages # Grep [0-9] /var/log/messages # Select all lines containing numbers in the '/var/log/messages' file grep Aug -r Sed 's/stringa1/stringa2/g' example. TXT # replace "string1" in example. TXT with "string1" "String2" sed '/^$/d' example. TXT # delete all blank lines from example. TXT; / ^ $/ d 'example. TXT # from example. TXT file delete all comments and blank lines echo' esempio '| tr / : the lower: "' [: upper:] '# sed merger and cell contents - e' 1 d ' Sed -e 's/ *$//' example. TXT # remove the last blank character from each line Sed -e 's/stringa1//g' example.txt # delete the word "string1" from the file and keep the rest of it; Sed -n '5p; sed -n '5p; 5 q 'example. TXT # to check the line 5 sed -e' 00 s / * / 0 / g 'example. TXT # replace multiple zero cat with a single zero - n cat file1 # label file lines example. TXT | awk' NR % 2 = = 1 ' # remove example. TXT file all even lines of the echo a b c | awk '} {print $1 '# to check the line of the first column echo a b c | awk' {print $1, $3} '# to check the line of the first and the third column paste file1 Paste -d '+' file1 file2 # Paste two files or two columns "+" to distinguish between sort file1 file2 # sort the contents of two files sort file1 file2 | uniq # remove two files and set (duplicate rows only keep a) sort file1 file2 | uniq - # u delete the intersection, Leave other line sort file1 file2 | uniq - d # remove the intersection of two files, leaving only exist in the two files in the file) file1 file2 comm - 1 # compares the contents of two files to delete "file1" only contains the contents of the comm - 2 Comm -3 file1 file2 # Compare the contents of two files and delete only the contents contained in 'file2'Copy the code
Character Settings and file format conversion
TXT # Convert a text file format from UNIX to MSDOS recode .. HTML < page. TXT > page. The HTML # convert a text file into HTML recode - l | more displays all # allows conversion formatsCopy the code
File System Analysis
Badblocks -v /dev/hda1 FSCK /dev/hda1 FSCK /dev/hda1 E2fsck /dev/hda1 e2fsck /dev/hda1 Ext3 /dev/hda1 fsck.vfat /dev/hda1 fsck.msdos /dev/hda1 FSCK Dosfsck /dev/hda1Copy the code
Example Initialize a file system
Mke2fs /dev/hda1 # create a Linux ext2 file system in hda1 partition mke2fs -j /dev/hda1 # create a Linux ext2 file system in hda1 partition MKFS -t vfat 32 -f /dev/hda1 # Create a FAT32 filesystem fdformat -n /dev/fd0 # Format a floppy disk MKFS -t vfat 32 -f /dev/hda1 Create a swap file systemCopy the code
SWAP file system
Create a swap file system swapon /dev/hda3 swapon /dev/hda2 /dev/hdb3 swapon /dev/hda3Copy the code
The backup
Dump-0aj -f/TMP /home0.bak /home # Make a full backup of '/home' directory dump-1aj -f/TMP /home0.bak /home # Make an active backup of '/home' directory restore -if/TMP /home0.bak # Restore an interactive backup rsync-rogpav --delete /home/tmp # synchronize the directories on both sides rsync-rogpav -e SSH --delete /home Ip_address :/ TMP # Rsync rsync-az -e SSH --delete ip_addr:/home/public /home/local # Synchronize a remote directory to a local directory rsync via SSH and compression - az - e SSH -- delete/home/local ip_addr: / home/public # via SSH and compression to local directory synchronization to the remote directory dd bs = 1 m if = / dev/hda | gzip | SSH user@ip_addr 'dd of=hda.gz' # backup the local disk on the remote host using SSH dd if=/dev/sda of=/ TMP /file1 # backup the disk contents to a file tar -puf backup.tar / home/user performs a of # directory '/ home/user' interactive backup operation (CD/TMP/local / && tar c.) | SSH - c user @ ip_addr 'CD/home/share / && tar x -p '# via SSH to copy a directory content in the remote directory (tar c/home) | SSH - c user @ ip_addr' CD/home/backup - home && tar - p 'x # via SSH in the remote directory replication a local directory tar cf - . | (cd /tmp/backup ; Tar xf -) # copy a directory to another location Retain the permissions and link the find/home/user1 - the name '*.txt' | xargs cp - av -- target - directory = / home/backup / # - parents from a directory to find and copy all in '. TXT ' At the end of the file to another directory, find the/var/log - the name '*. The log' | tar CV - files - from = - | bzip2 > the tar. The.bz2 # to find all 'log' at the end of the file and make a bzip package dd If =/dev/hda of=/dev/fd0 bs=512 count=1 dd if=/dev/fd0 of=/dev/hda bs=512 Count =1 # Restore MBR contents from backup already saved to floppy diskCopy the code
CD
Cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank= fast-force # delete the contents of a copyable CD mkisofs /dev/cdrom > cd.iso # on disk to create a CD iso image file mkisofs/dev/cdrom | gzip > cd_iso. Gz # on disk to create a compressed the cd-rom iso image files 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 # create an ISO image file gzip -dc Cd_iso. Gz | cdrecord dev = / dev/cdrom - # burn a compressed the ISO image file mount -o loop CD. ISO/MNT/ISO # mount an ISO image file CD, paranoia, and B # transcription from a CD tracks to wav files in CD - paranoia -- "- 3" # transcription from a CD tracks to wav file (parameters - 3) cdrecord scanbus #, scan bus in order to identify the SCSI channel dd if = / dev/HDC | Md5sum # Verify the MD5SUM encoding of a device, such as a CDCopy the code
Networking – (Ethernet and WIFI wireless)
Ifconfig eth0 # Show the configuration of an Ethernet card ifup eth0 # Enable an 'eth0' network device ifdown eth0 # disable an 'eth0' network device ifconfig eth0 192.168.1.1 netmask 255.255.255.0 # Control IP address ifconfig eth0 promisc # Set 'eth0' into promiscuous mode to sniff packets dhclient eth0 # Enable 'eth0' route-n in DHCP mode Route add-net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 '192.168.0.0/16' route del 0/0 gw IP_gateway 'hostname' host www.example.com Resolve a host name to an Internet address or resolve an Internet address to a host name. Nslookup www.example.com # Used to query DNS records, check whether domain name resolution is normal, used to diagnose network problems when network faults. Netstat -tupl tcpdump TCP/UDP port tcpdump TCP/UDP port 80 # Displays all HTTP trafficCopy the code
Finally, here is an electronic copy of the manual similar to this article, as follows:
This information is very comprehensive and detailed, from Linux common commands to Linux common operations, and then to network management, performance optimization, almost covering all aspects of Linux learning, very suitable for beginners, can also be used as a quick check manual!
Each knowledge point has left navigation bookmark page, it is very convenient to see, because the content is more, here is a part of the picture. You can get this Linux quick guide for free if you like it!
The material is also organized by table of contents, with more specific content below each chapter:
Moreover, this information is not a scanned version, the text inside can be directly copied, very convenient for us to learn:
The last
All the learning materials and interview materials in the above content can be provided free of charge. I hope you can have a smooth interview and win your favorite offer! Need friends click here, there are Java core knowledge points + a full set of architect learning materials and video + a large factory interview treasure book + interview resume template + Ali Meituannetease Tencent Xiaomi IQiYI Quick hand bilibili bilibili interview questions +Spring source code collection +Java architecture actual practice e-books together free to share with you!
Scan the image below for free information: