This article contains a few useful things that can be done in terminal; with explanations of what they do and why. I'll continually add to this list as I learn more.
Exclude SVN and GIT Files While Backing Up a Directory
If you're like me, you have quite a few projects that use a mix of SVN and GIT version control systems. You may want to exclude all those hidden SVN and GIT files from your backup:
sudo tar --exclude-vcs -zcvf ./backup.tar.gz /path/to/projects/directory
Limit Download Speed for Large File Downloads
If you've ever needed to download a very large file, but didn't want to completely tie up your internet connection's bandwidth, you're going to love this:
cd ~/Downloads wget --limit-rate=500k http://url-of-file-to-download
wget does a GET request to a specified URL. The --limit-rate option sets a maximum download speed for this download.
Output Result of a Terminal Command to a File
Sometimes when using terminal, a command will generate such a large amount of output that it gets cut-off towards the beginning. The way to view the full output is by writing it to a file:
ls -l > output.txt
Now if you open output.txt in gedit you should see a list of all the visible files and directories within the current user's home directory.
Pipe the Output of One Command into Another
Sometimes it's helpful to chain commands together, like this:
ls -l | grep somefile
ls lists the contents of the current directory. And, grep does pattern matching on the string that is passed to it. The net result of this combination is finding all files in the current directory that at least partially match the text somefile
Search Running Processes by Keyword
Here we're going to pipe the output of the ps aux command - which lists all running processes - into grep with a keyword, to retrieve a list of running processes that matches our keyword:
ps aux | grep ssh
Where ssh is our keyword.
Manually Expire/Exit Sudo Session
After you've used sudo to execute a terminal command, the sudo session will persist for some time after. What this means is that you won't be prompted for the password for the root user when using sudo during this session. To expire the sudo session do the following:
Exit su Session
To manually exit from a su - someuser session: