securitybreach Posted January 14, 2015 Share Posted January 14, 2015 Let us start new year with these Unix command line tricks to increase productivity at the Terminal. I have found them over the years and I'm now going to share with you. Deleting a HUGE file I had a huge log file 200GB I need to delete on a production web server. My rm and ls command was crashed and I was afraid that the system to a crawl with huge disk I/O load. To remove a HUGE file, enter: > /path/to/file.log # or use the following syntax : > /path/to/file.log # finally delete it rm /path/to/file.log Want to cache console output? Try the script command line utility to create a typescript of everything printed on your terminal. script my.terminal.sessio Type commands: ls date sudo service foo stop To exit (to end script session) type exit or logout or press control-D exit To view type: more my.terminal.session less my.terminal.session cat my.terminal.session Restoring deleted /tmp folder As my journey continues with Linux and Unix shell, I made a few mistakes. I accidentally deleted /tmp folder. To restore it all you have to do is: mkdir /tmpchmod 1777 /tmpchown root:root /tmpls -ld /tmp Locking a directory For privacy of my data I wanted to lock down /downloads on my file server. So I ran: chmod 0000 /downloads The root user can still has access and ls and cd commands will not work. To go back: chmod 0755 /downloads Password protecting file in vim text editor Afraid that root user or someone may snoop into your personal text files? Try password protection to a file in vim, type: vim +X filename ............ http://www.cyberciti...-tricks-part-i/ 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.