Some common commands of linux

Environment ubuntu4.4

Clear the screen: clear

History commands:

     View: history 

     Clear: history -c

Run as root account: sudo -i

ip address view: ip addr or ifconfig -a

ssh remote connection: ssh account@ip address

Transfer files remotely:

              Local to remote: scp local file account@ip address: remote directory

              For example: scp /usr/test.txt [email protected]:/root/remote_test.txt

              Remote to local: scp account@ip address: remote directory local file directory

Compress/decompress:

    Packaging: tar -cvf package name.tar folder name

    Unpack: tar -xvf packagename.tar

    Compression: tar -zcvf package name.tar.gz folder name (-z represents gz compressed package, -v represents whether to display the process)

             zip package name.zip folder name

    Decompression: tar -zxvf package name.tar.gz  

             unzip package name.zip

Find a file (folder): find / -name filename

Create a folder: mkdir folder name (recursively create a directory mkdir -p folder path)

Move all files in a folder to another folder: mv folder to be copied/* target folder/

Delete a file (folder): rm -rf filename

Empty the recycle bin: rm -fr $HOME/.local/share/Trash/files/*

Start a program: full path or relative path (/tomcat/bin/startuo.sh or ./bin/startup.sh)

Run the sh script: bash xxx.sh or /xxx/yy/aaa.sh (script path)

Install a program: apt install package name or apt-get install package name

Port view: lsof -i: port or netstat -ap | grep port

Close/exit process, service: kill -9 process id (-9 means exit, will not cause system blocking)

Check if a service is running: service --status-all | grep service name (+ means running - means not running)

system service:

      Start: service service name start 

      Close: service service name stop

      Restart: service service name restart

vi, vim related:

     Edit a file: vi filename

     Toggle edit mode: i (in editor)

     Switch command mode: press esc (in editor)

     Delete the current line: dd

     find: /find content (find backwards, enter n to go to the next, enter N to go to the previous)

              ?Find content (look forward, enter N to go to the next, enter n to go to the previous)

     Page turn: press ctrl+b (turn forward one page, b stands for backforward)

              Press ctrl+f (turn one page back, f stands for forwardforward)

     Undo the previous step: press ctrl+u

     Undo one step: press ctrl+r

     quit::wq (save and quit) :q! (discard all modifications and exit)

tomcat related:

     Query real-time logs: tail -f /logs directory/catalina.out

 

     

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325483850&siteId=291194637