编程知识 cdmana.com

Linux enter directory command

Go directly to the computer directory

img

img

img

Commonly used instructions

cd /home Get into '/ home' Catalog ' cd .. Return to the previous directory cd ../.. Returns the two directories above cd Enter personal home directory cd ~user1 Enter personal home directory cd - Return to last directory ls   Show files or directories -l List file details l(list) -a List all files and directories in the current directory , Include hidden a(all) mkdir Create directory -p Create directory , If there is no parent directory , Create p(parent) cd Toggle directory touch Create an empty file echo Create a file with content . cat View file contents cp Copy mv Move or rename rm Delete file -r Recursive delete , Can delete subdirectories and files -f Mandatory deletion find Search the file system for a file wc Count the number of lines in the text 、 Number of words 、 Number of characters grep Find a string in a text file rmdir Delete empty directory tree The tree structure shows the directory , Need to install tree package pwd Show current directory ln Create link file more、less Page by page display of text file content head、tail Show header 、 Ending content ctrl+alt+F1 Command line full screen mode

img System management command

stat Show details of the specified file , Than ls A more detailed who Show online login users whoami Display the current operating user hostname Display host name uname Display system information top Dynamic display of process information that currently consumes the most resources ps Show transient process status ps -aux du Check the catalog size du -h /home With unit display catalog information df Check the disk size df -h With unit display disk information ifconfig Check the network ping Test network connectivity netstat Display network status information man Orders don't work , Looking for a man Such as :man ls clear Clear the screen alias Rename the command Such as :alias showmeit="ps -aux" , In addition, the use of unaliax showmeit kill Kill process , You can use first ps or top Command to view the id, And then use kill Order to kill the process .

Package compression related commands

gzip: bzip2: tar:
-c Packaging compression -x Unzip the file -z gzip Compressed files -j bzip2 Compressed files -v Shows the compression or decompression process v(view) -f Use file name

example :

tar -cvf /home/abc.tar /home/abc Pack only , Uncompressed tar -zcvf /home/abc.tar.gz /home/abc pack , And use gzip Compress tar -jcvf /home/abc.tar.bz2 /home/abc pack , And use bzip2 Compress Of course , If you want to decompress , Just replace the above command tar -cvf / tar -zcvf / tar -jcvf Medium “c” Switch to “x” That's all right. .

To turn it off / Restart the machine shutdown -r Shut down and restart -h Shut down without restarting now Turn off immediately.

halt To turn it off reboot restart Linux The Conduit Take the standard output of one command as the standard input of another . That is to combine several commands , The result of the latter command in addition to the previous one . example :grep -r "close" /home/* | more stay home All files in the directory , Include close The file of , And pagination output .

Linux Package management

dpkg (Debian Package) Management tools , Package name with .deb suffix . This method is suitable for the case that the system can not be connected to the network . Such as installation tree Command installation package , First the tree.deb to Linux In the system . Then use the following command to install . sudo dpkg -i tree_1.5.3-1_i386.deb Install the software sudo dpkg -r tree Uninstall software notes : take tree.deb to Linux In the system , There are many ways .VMwareTool, Use mount mode ; Use winSCP Tools etc. ; APT(Advanced Packaging Tool) Advanced software tools . This method is suitable for the situation that the system can connect to the Internet . Still in tree For example sudo apt-get install tree install tree

sudo apt-get remove tree uninstall tree

sudo apt-get update Update software sudo apt-get upgrade
take .rpm The file to .deb file .rpm by RedHat The software format used . stay Ubuntu You can't use it directly , So we need to change . sudo alien abc.rpm vim Use vim Three models : Command mode 、 Insertion mode 、 Edit mode . Use ESC or i or : To switch modes . In command mode : :q sign out :q! Forced exit :wq Save and exit :set number According to the line Numbers :set nonumber Hide line numbers /apache Find... In the document apache Press n Skip to the next ,shift+n the previous yyp Copy the line where the cursor is , And paste h( Move one character to the left ←)、j( The next line ↓)、k( Last line ↑)、l( One character to the right →)

User and user group management

/etc/passwd Store user accounts /etc/group Storage group account number /etc/shadow Store the password of the user's account /etc/gshadow Store password of user group account useradd user name userdel user name adduser user name groupadd Group name groupdel Group name passwd root to root Set the password su root su - root /etc/profile System environment variable bash_profile User environment variable .bashrc User environment variable su user Switching users , Load profile .bashrc su - user Switching users , Load profile /etc/profile , load bash_profile

Change the user and user group of the file

sudo chown [-R] owner[:group] {File|Directory} for example : Also with jdk-7u21-linux-i586.tar.gz For example . Belongs to the user hadoop, Group hadoop To switch users and groups to which this file belongs . You can use commands .

sudo chown root:root jdk-7u21-linux-i586.tar.gz

That's all Liangxu tutorial website For all of you Linux Related knowledge .

版权声明
本文为[Pioneer of code farmers]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/02/20210201031608445b.html

Scroll to Top