Essential terminal tricks you should know

Here are few of my favorite terminal tricks that might be useful to other users as well.

1. Your live media automatically logs you in but you need to set a custom DPI value, Press Control+ALT+F3 (usually also F4,F5,F6 will work) and open another instance of a virtual terminal. The actual number of terminals depends upon system settings. From another virtual terminal instance you can easily start a new session. This time around the automatic login should not happen since the live media already has reached this goal with the initial instance. This trick might not work with heavy window managers but with lightweight ones it should work just fine.

2. Need to move/copy/rename/remove files from sudo/root owned folder. Became a root user and execute:

rm -r some_file   #remove a file.
rm -r some_folder   #remove a folder.

cp -r some_file   some_location   #copy a file to a location.
cp -r some_folder   some_location   #copy a folder to a location-

mv some_content   some_location   #move something to somewhere.

mv /home/user/some_file_old   /home/user/some_file_new   #rename an object.

Keep in mind that the terminal asks no questions in regular tasks. This means that when you move/copy/rename etc. be careful what you type because once the procedure begins anything with a similar name gets destroyed out of the way.

If you are not having a root account then just put sudo in front of every command in order to get into the super-user mode.

The Gui way of doing things is also simple:

sudo file_manager_name

For example: sudo sfm

Note of caution. Gui’s can crash.  In an ideal scenario you should try to use terminal whenever possible. For example, I had a pcmanfm crash about 4 years ago, which ended up destroying some of my files that were moved at the same time. 

3. Mounting the media via terminal. I did Simple mount awhile back, which is essentially a helper program for command line mounting and unmounting.

However, you can easily do the same with these commands.

First find the media with lsblk command.
Mount it with sudo mount /dev/sdbX   usb #letter b points to the media and letter X points to the partition you want to mount. Usb is the mount point.

The whole proceses of mounting an usb device called sdb and its partition 1 might go something like this:

mkdir usb   #create a folder usb
sudo mount /dev/sdb1   usb   #mount the device to the folder usb
Now the folder should appear containing your usb/portable media content in it.
Once you are done execute sudo umount usb to unmount the device.

4. View files and folders

Use either ls or dir commands. Personally, I prefer the dir command.
the view hidden files and folders you can do: dir -a or ls -a

I usually prefer using either the terminal or a dedicated program to view hidden files. In most cases you should be cautious when accessing hidden files – since they are likely hidden for a reason. Deleting or accidentally modifying a hidden file can ruin system settings and stability. Gnome programs usually respect Control+h combination , which will let you view hidden files and folders.

Perhaps the most useful way of viewing hidden content is through text editors. For example, you can click File –> Open in Geany text-editor and then select a pathway and press Control+h to display the hidden files or folders. Based on my experience, using text-editors to view hidden elements is the way to go. Using a text-editor gives user some time to think before he/she does something – and this might prove to be useful in accidental damage prevention.

Hint. You can differentiate hidden files and folders from the non-hidden ones by looking if they have a dot in front of their name.

For example: