20 unix/linux Command Tips

Source: Internet
Author: User
Tags tmp folder password protection

Let's start the new year with these unix/linux command tricks to improve productivity at the end. I have been looking for a long time to share with you now.


Delete a large file
I have a large 200GB log file on the production server that needs to be deleted. My RM and LS command has crashed and I'm worried that this is caused by huge disk IO, to delete this large file, enter:
>/path/to/file>/path/to/filerm /path/to/file. log

How to record terminal output?
Try using the script command-line tool to create an output record for your terminal output.
Script My.terminal.sessio

Enter the command:
ls Date sudo service foo stop
to exit (end the script session), enter exit or logout or press control-d
To browse for input:
 More my.terminal.session  Less my.terminal.session Cat My.terminal.session

Restore the deleted/tmp folder
I am in the article Linux and Unix shell, I made some mistakes. I accidentally deleted the/tmp folder. To restore it, I need to do this:
mkdir /tmpchmod1777 /tmpchown root:root/tmpls -LD /tmp

Lock a folder
For my data privacy, I want to lock the/downloads folder under my file server. So I ran the following:
chmod 0000 /downloads

Root users still have access, while the LS and CD commands do not work. To restore it by:
chmod 0755 /downloads
Password-protect files in vim
Afraid of the root user or someone else spying on your personal files? To try a password protection in vim, enter:
Vim +x filename
Alternatively, use the: X command to encrypt your file before exiting Vim, and Vim will prompt you to enter a password.

Clear garbled on the screen
Just enter:
Reset

Easy-to-read format
Pass the-H or-H (and other options) options to the GNU or BSD tool to get commands like LS, df, Du, and more in an easy-to-read format output:
ls-lh# in an easy-to-read format (for example: 1K 234M 2G)DF-hDF-k# output in bytes, KB, MB, or GB: Free-b Free-k Free-m Free-g# output in an easy-to-read format (e.g. 1K 234M 2G)du-h# displaying file system permissions in an easy-to-read formatStat-C%A/boot# more readable numbersSort-h-afile# Display CPU information in easy-to-read form on Linux lscpulscpu-elscpu-e=cpu,node# Displays the size of each file in an easy-to-read format tree-Htree-h/boot
via:http://www.cyberciti.biz/open-source/command-line-hacks/20-unix-command-line-tricks-part-i/

Nixcraft
Translator: GEEKPI
Proofreading:

20 unix/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.