Linux Command Tips

Source: Internet
Author: User
Tags gpg tmp folder password protection

1. Delete a large file

#创建空的大文件 #dd if=/dev/zero of=test ibs=1k count=10240000#ll-h test-rw-r--r--. 1 root root 9.8G June 12:10 test# First empty the contents of the file and then delete the file (>test or: >test) #>test#ll-h test-rw-r--r--. 1 root root 0 June 12:12 test# Delete file rm-f test


2. Use the script command-line tool to create output records for the terminal output:

#script My.sessio #创建终端输出文件模式, all subsequent commands and outputs will be output to this file script started, file is My.sessio#pwd/root#whoroot tty1 20 18-06-11 11:06#exit #输入exit或者logout或者按下ctrl +d will exit the recording mode Exitscript done, the file is my.sessio# view the output distance #more my.sessio#less My.sessio #查看中文会乱码 #cat My.sessio


3. Restore the deleted/tmp folder

#mkdir/tmp#chmod 1777/tmp#chown root:root/tmp#ls-ld/tmp


4. Lock a folder

#chmod 0000/test#root users still have access, and the LS and CD commands do not work. To restore it by: #chmod 0755/downloads


5. Password-protect files in vim

#害怕root用户或者其他人偷窥你的个人文件么? Try to use the password protection in vim but the root user can modify, just to encrypt the file! Input: #vim +x filename or, use the: X command to encrypt your file before exiting Vim, and Vim will prompt you to enter a password.


6. Clear garbled on the screen

#reset


7. Output in human readable mode

ls-lh# in an easy-to-read format (e.g. 1K 234M 2G) df-hdf-k# in bytes, KB, MB, or GB output: free-bfree-kfree-mfree-g# output in an easy-to-read format (e.g. 1K 234M 2G) du-h# to Easy-to-read format displays file system permissions stat-c%a/boot# more readable numbers sort-h-a file# display CPU information in easy-to-read form on Linux lscpulscpu-elscpu-e=cpu,node# displays the large of each file in an easy-to-read form Small tree-htree-h/boot


8. Display of known user information on Linux systems

Lslogins


9. How to delete files that were accidentally extracted under the current folder

Use the-t option in tar to list the archive file name, and then rm-f delete #rm-rf ' tar ztf uws.tar.gz '


10. Use Htop to display system process information, more at a glance

#rpm-IVH http://mirrors.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm#rpm--import/etc/pki/rpm-gpg/ rpm-gpg-key-epel-6# Yum Install Htop#htop


11. Some quick ways to operate

cd-#进入上一条命令的路径下cd #进入用户家目录!! #再次运行上一条命令


12. List all directories or files in the system

Find/-type d|lessfind/-type f|less

13. Copy Files to multiple directories

#echo dir1 dir2 dir3 dir4 dir5|xargs-n 1 cp-v ~/test.py


14. Use tee to output and write to a file simultaneously on the screen

#tree | Tee My.Log


15. Interpreting binary files

# utmpdump/var/log/wtmp

16. Pending update ...



Linux Command Tips

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.