Linux Shell/Terminal Commands

Linux can run in a shell/terminal mode and a lot of difficult tasks are easier to execute in this mode. One such task is searching for a type of file and all instances of it in a directory tree and moving them to another directory.

Switch to the directory where you’d like to begin and then the syntax is…
find -name *.jpg -exec mv {} /jpgDirectory \;

The ; terminates the line and \ tells Linux to ignore the next character and the {} uses the found filename.

Another common task is joining files and sorting them as you do it.

cat file1 file2 | sort > output.txt

Another common task is mounting a drive. The syntax is like..
sudo mkdir mydrive
sudo mount -t auto /dev/sdb1 mydrive

to unmount first exit the directory tree of the device then…
sudo umount /dev/sdb1

Simple huh?

To install Java…
first: sudo apt-get update

second check to see if java is installed: java -version

third install java: sudo apt-get install default-jre

fourth and/or the jdk: sudo apt-get install default-jdk

Often after uninstalling a program you’ll get message in the terminal from the apt-get program that says “The following packages were automatically installed and are no longer required:” and it will give you a list.
You can safely remove any of these packages using…

sudo apt-get remove thepackagename

or you can do it all at once with…

sudo apt-get autoremove

other useful commands are…
sudo apt-get update [updates the system]
and
sudo apt-get clean