Terminal Tricks part II
March 27th, 2008
Useful stuff when you are using the terminal
man [anycommand]
Can't believe I left that off... one of the most useful commands for figuring out what a command does, read the "man" (manual) page. Now that is easy to say but, you may need some help navigating it so to help with that use these commands:
q
Quit man
f
Go forward a page
b
Go backward a page
/string
Search for 'string'
Need even more help? you can always:
man man
Forget to sudo a command? just:
sudo !!
Need to reference something in your home directory?
prefix your path with ~/
Want to search for look for a specific line of text inside a file?
cat /the/file/path || grep 'what you are looking for'
ex: cat /etc/apache2/httpd.conf || grep 'http'
Grep (used above) can be used on any command as shown above you can "pipe" the output of one command to another. So you could use ls, cat, tail etc and search the output of that command with grep.
Need to watch some log file output?
tail -f /the/log/file.log
Want to create a shortcut to a command? You need to edit your .bash.profile. Open up your home directory and if the file doesn't exist create it. (make sure it is ".bash_profile" - notice the prefixing period). Now create your alias: (this particular alias lets you see colored output on the ls command.
alias ls='ls -GF'
Need to change ownership of a file? use chown
chown user:group /path/to/file.txt
Thats it for now, hope it helps you out.
April 18th, 2008 at 08:08 AM
This is so amazing. It reminds me of the good old Apple II days.