Linux Tips & Tricks (Ubuntu/Debian/Mint/Kali)

ubuntu-logo-8647_640

1. Fully update the system from the Command Line.

Step 1 – From the command line, run the following commands:

sudo apt-get update 
sudo apt-get dist-upgrade

Step 2 – Reboot if necessary.

sudo reboot -h now

Step 3 – Close and exit.

2. Install Dropbox onto Linux (Ubuntu) from the CLI.

Step 1 – 32-bit: $

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -

Step 1 – 64-bit: $

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -

Step 2 – $

~/.dropbox-dist/dropboxd

Step 3 – Having problems with Dropbox not automatically starting upon reboot? Try the following installation CLI command.

sudo apt-get install nautilus-dropbox

Step 4 – Now right click on the Dropbox notification icon (bottom right of Linux Mint 15), choose “Preferences”, and ensure that ” Start Dropbox on System Startup” is checked!

Step 5 – Ever want to check on the status of Dropbox? Then just use the below linux CLI command.

dropbox status

3. Unmount a USB from the command line.

Step 1 – Use the following command to view the currently mounted drives within linux:

df -h

Step 2 – Use the following command to unmount your selected USB, where N is the annotation of your drive (eg sda1 etc):

umount /dev/sdbN

Unmount via the Terminal

4. Check the system’s Graphics/Display information.

Step 1 – Use the following command to view the system’s graphics/display information:

sudo lshw -c video

Display Information

5. Install Shutter from the Debian CLI.

Step 1 – Use the following command to install the excellent screen-capturer, Shutter:

sudo apt-get install shutter

6. Installing Chromium-browser in Debian using the CLI.

Step 1 – Open the Terminal and type the following commands into the prompt:

For 32 bit:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb 

For 64 bit:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

sudo dpkg -i ./google-chrome*.deb

OR, if the above that isn’t working then try this….

sudo apt-get install chromium-browser

7. Installing Boxcryptor in Linux.

Step 1 – Open the Software Manager and install both encFS and Cryptkeeper.

Step 2 – Open Cryptkeeper and point it to the location of your Boxcrytpor database (within Dropbox, eg: boxcryptor.bc).

Step 3 – Point the Cryptkeeper software to the location where you would like your “virtual” Boxcryptor drive/folder to be, and create the folder if you haven’t already.

Step 4 – Save and exit. To restart the software, just ALT-F2 and type “cryptkeeper” to start the application.

8. Installing ClamAV in Debian.

Step 1 – Open the terminal and use the following command:

sudo apt-get install clamav clamtk

Step 2 – Update ClamAV’s definitions with the following command.

sudo freshclam

9. Installing Docky in Linux Mint.

Step 1 – Open the terminal and use the following command:

sudo apt-get install docky

10. Adding the Google software repositories public key via the CLI in Ubuntu/Linux Mint.

Step 1 – Open the terminal and use the following command:

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

11. Adding MS Office jpg libraries (for Crossover) in Linux Mint via the CLI.

Step 1 – Open the terminal and use the following command:

sudo apt-get install libjpeg62

12. Install Minecraft in Linux Mint 15 via CLI.

Step 1 – Open the terminal and use the following command:

sudo add-apt-repository ppa:minecraft-installer-peeps/minecraft-installer
sudo apt-get update
sudo apt-get install minecraft-installer

13. Install Ubuntu One in Linux Mint 15 via CLI.

(Service Discontinued)

Step 1 – Open the terminal and use the following command:

sudo add-apt-repository ppa:noobslab/apps
sudo apt-get update
sudo apt-get install ubuntuone-client ubuntuone-control-panel ubuntuone-client-proxy ubuntuone-control-panel-qt

14. Check for damage to the RAM from the CLI in Ubuntu/Linux Mint/Debian.

Step 1 – Open the terminal and Firstly, check to see if memtester is already on your system:

which memtester

Step 2 – If it isn’t on your system, install it with:

sudo apt-get install memtester

Step 3 – Initiate the test using….. (where “5” is the number of times you wish the test to run, and 2000 the amount of RAM in mb):

memtester 2000 5

Step 4 – Type the command “echo $?” to show the exit code when you see a command prompt again. If the output is “0,” the memory is working properly. The other possible outcomes are:

x01: Error allocating or locking memory, or invocation error

x02: Error during stuck address test

x04: Error during one of the other tests

15. Repair MBRs with a Linux (Ubuntu OR Linux Mint) Live USB.

Step 1 – Use a Linux Live USB to boot the computer with a corrupted MBR.

Step 2 – Once in Linux open the terminal and use the following commands to install Boot Repair:

sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
sudo apt-get update
sudo apt-get install -y boot-repair &&boot-repair

Step 4 – Run the newly installed Boot-Repair and fix the MBR of the computer you booted using the Linux Live USB.

16. Add a larger repository in Ubuntu/Linux Mint; and add Ubuntu-Tweak.

Step 1 – Do the following from your terminal.

sudo add-apt-repository ppa:tualatrix/ppa
sudo apt-get update
sudo apt-get install ubuntu-tweak

17. Fix the Linux Mint audio HDMI output.

Step 1 – If the Linux Mint HDMI audio output is not working out-of-the-box, then use the following bash commands:

sudo add-apt-repository ppa:ubuntu-audio-dev/alsa-daily
apt update
apt install oem-audio-hda-daily-dkms

18. Use Switcheroo to manage hybrid graphics in Ubuntu.

(Gratefully reproduced in part from Ubuntu Community Help here)

Step 1 – The Vga_Switcheroo flag has been used to manage hybrid graphics adapters in laptops for a while now, and it began being shipped as part of Ubuntu since 10.10. Vga_Switcheroo only works on certain machines, and only with the open-source drivers (nouveau, radeon). As previously mentioned, you can determine your particular graphics hardware and drivers with:

sudo lshw -c video

Step 2 – To check whether your kernel is compiled with the proper option to run Vga_Switcheroo, type the following as the BASH prompt:

grep -i switcheroo /boot/config-*

Step 3 – Vga_Switcheroo will only be active if the kernel is booted with either the “modeset=1” option and/or the “nomodeset” option being absent.

…..under construction.

19. Check the MD5 sum of a downloaded file in Ubuntu.

(Gratefully reproduced in part from Ubuntu Community Help here)

Step 1 – Most modern Linux distros come with “md5sum” installed (especially the Ubuntu family). One way to check if md5sum is installed on your system is to try:

md5sum --help

If you get an affirmative answer, then md5sum is installed on your system (see below)

The result of: md5sum --help

The result of: md5sum –help

Step 2 – Once you determine that you have md5sum installed (or that you didn’t, and you have installed it via your distro’s repositories), navigate your Bash prompt to the directory containing the file you would like to authenticate and prefix the file name with ‘md5sum’. The resulting output is the file’s md5 hash; compare that to the md5 hash from the file’s provider (your disto’s download page in the case of a Linux .ISO), and providing they match exactly, your file is authenticated and intact. See below for an example:

md5sum

 

UPDATE – 6 Feb 2015

The use of the MD5 algorithm to generate hash keys to confirm the security of software files is no longer considered safe, and hasn’t been best practice for a while now.  For the time being, the most commonly used algorithm which is complicated enough to afford some protection against Hash-key manipulation is SHA1

20. Establish unattended upgrades in Ubuntu 13.

(Gratefully reproduced in part from Ubuntu Community Help here)

Step 1 – Ensure that the latest version of unattended-updates is installed within your Ubuntu 13.-04 system:

sudo apt-get install unattended-upgrades

Step 2 – Configure unattended-upgrades to fit your needs by editing /etc/apt/apt.conf.d/50unattended-upgrades.

Step 3 – Enable unattended-upgrades set your desired values via editing /etc/apt/apt.conf.d/10periodic.

There is plenty more information regarding the unattended-upgrades package in the below link to the Ubuntu Community website. I encourage you to check it out!

https://help.ubuntu.com/13.04/serverguide/automatic-updates.html

21. Grab some essentials from the Ubuntu Software Centre following install.

Step 1 – From within the Ubuntu Software Centre, download Steam and Ubuntu restricted extras as soon as you can following a Ubuntu install.

22. Add the Show Desktop and Multiple Workspaces icons to the Unity launch bar.

Step 1 – Open settings, click on Appearance, and select Behaviour.  Click on the Enable workspaces & add show desktop icon to the launcher.

Click Show Desktop & Show Workspaces

Click Enable Workspaces & add Show Desktop icon to the launcher.

22. Install some decent Bluetooth management software (instead of the standard Ubuntu BT app).

Step 1 – Install the following decent Bluetooth apps:

sudo apt-get install bluetooth blueman bluez-hcidump bluewho python-bluez bluez-tools

Step 2 – Start using the new Bluetooth apps from the settings folder OR from within the system tray in the top right corner of the screen.

23. Install Everpad (Evernote linux clone) within Ubuntu 13.10.

Step 1 – Add the Everpad apt repository with:

sudo add-apt-repository ppa:nvbn-rm/ppa

Step 2 – Next, update the system and install Everpad:

sudo apt-get update
sudo apt-get install everpad

See the entry for Everpad within the page “Ubuntu 13.10” as the above apt-get install method no longer works in Ubuntu 13.10.

23. Copy files / Manage Permissions.

Use cp to copy files from within the Linux bash-shell (Bourne-again shell shell; it’s sort of like PIN Number). Examples:

sudo cp script.sh /bin

Use the above to copy a script to the /bin directory.  Root is needed due to the permissions associated with /bin.

The above bash command assumes that the file being copied (source file) is within the same working directory as the user is currently located. pwd (print working directory) should let you know where you are. Alternatively ls, might also give you an idea, if the prompt doesn’t already suggest the user’s current directory location.

sudo cp -p /home/matt/Desktop/script.sh /bin

Here the above syntax copies the same “script.sh” script, but from the user’s Desktop directory, for times when they are within another working directory.  The destination directory for script.sh is still the ~/bin location, but the “-p” argument commands cp to honour all of the file’s existing permission’s (i.e: current read/write/execute permissions).  In the case of a script being copied to /bin (to enable it to be run easily from the terminal), it will need to be made executable for any user the administrator deems appropriate.

In order to set the file’s permissions to allow any user execute rights, the following chmod command should be used (+/- sudo as needed):

chmod a+x /path/to/file/script.sh

This way, any user will be able to execute the script (thanks to the “a+x”).  For occasions where an admin needs to set read/write/execute permissions for the owner of a file, chmod 700 is used a-la.. (again +/- root/super user as needed)

chmod 700 /path/to/file/script.sh

Next, execute the script as a basic user by just entering the script filename (depending if the script is intended to be used by regular user accounts).  If the user is already within the same working directory as the file, then “./” is all the needs to be prefixed to the command; otherwise the full “/path/to/file/script.sh” should be used.  Examples:

ls
pwd
/path/to/file/script.sh

OR

pwd
./script.sh

24. SSH – Using Secure SHell for remote command line access across a LAN. 

The Secure Shell tool is especially useful to remotely administer computers on the same network as the administrator.  For headless computers residing on a home network (such as a Raspberry Pi home automation/home security/file server), a running ssh-server is an essential application.

Most modern Linux distros with come ssh already installed, almost all others will have it within their repositories.

Using the ifconfig on the target computer will provide you with the assigned IP address.

ifconfig

Armed with the target computer’s IP address, establish a secure shell connection by logging in with the ssh command:

sudo ssh pi@192.168.0.17

Type your local machine’s administrator/superuser password.

Then, when prompted, enter the target machine’s user password.

Finally, select “Yes” as appropriate to accept the target computer’s crypto-key.

In addition, as is the case in my place, I am regularly sshing into my various Raspberry Pi’s which may share IP addresses across my local network.  This can result from using the same ethernet cable to attach different machines, at different times OR by swapping out the Raspberry Pi’s SD Card, in effect changing the operating system of the target machine.

If this is done, the next time you attempt to log into a target machine, your local shell will throw up a warning about the likelihood that you are falling victim to a “man-in-the-middle attack” as the previously generated RSA keys have changed.

To address this, use gedit or nano to delete the previously generated key from the ssh_knownhosts file OR add the new key to the same file, remembering to CTRL-O to save using the same name, and CTRL-X to exit.  The next time you attempt to ssh using that IP address, you will be prompted to accept a newly generated RSA crypto-key as local machine believes this is the first time a ssh connection has been attempted to a machine at this IP.

25. Burn a Boot USB from the Command Line using dd

Download your favourite flavour of Linux.

Confirm the USB ID using df -h or other similar drive information tools.

df -h

If you need further information regarding the USB, use sudo fdisk -l /dev/sdb and study the output.

sudo fdisk -l /dev/sdb

Using the Terminal, navigate to the folder containing the .ISO file.pwdcd Downloadslsor, if the folder is full of other files, easily locate your file by narrowing the search to just .ISOs with:ls *.iso

Locating the USB.

Locating the USB.

Since the Linux Mint 17 .ISO is a Hybrid image, dd can be used with ease to create a bootable USB drive (without a persistence state, which can be added with Unetbootin if needed).Note: using dd contains significant risks.  As dd will format the target drive during the image burn, all data contained on the disk will be destroyed.

As always, take care to ensure that you remove your valuable data from the target drive before you commit to using dd.  Furthermore, the utmost care must also be taken to ensure that you have used the correct target drive identification within the dd command.  Use of an incorrect drive identification may result in the destruction of a system partition (or partitions) on the computer’s hard-drive, instead of the USB.  It only takes a typo to go from /dev/sdb to /dev/sda, and if that were to happen, the excrement may hit the fan (so to speak).

sudo dd if=linuxmint-17.1-cinnamon-32bit.iso of=/dev/sdb

Once finished, eject the USB and use as required.sudo eject /dev/sdb

Burning the .ISO image with dd

26. Using the CLI to work with the Linux Kernel.

To display the kernel release:

uname -r

Display the version:

uname -v

To print all kernel information:

uname -a

Display the operating system:

uname -o

27. Install the “Terminal” heading (& therefore terminal emulation support) in Geany (if missing).

To get the Terminal heading, and emulator back into the Python IDE, Geany, install libvte9 (which may be missing from your Ubuntu installation) via:

sudo apt-get install libvte9

Once installed, open Geany and verify that the “Terminal” heading is now present.

As libvte9 is a suggested package for Geany, it may not be installed by default depending on your Distribution and the version of Geany residing within it’s repositories.

If you want to check Geany (or any other program’s) dependancies, just use the apt-cache depends command, a la:

apt-cache depends geany

The output of which details both the required AND suggested packages for Geany (or any other program in your distro’s repositories).

Geany's dependent AND suggested packages.

Geany’s dependent AND suggested packages (Note the highlighted package libvte9)

28. Create a non-root user in Kali Linux.

(This information is a re-creation of the BlackMoreOPS guide to creating a non-superuser account for Kali GNU/Linux available here.)

(P.P.S. Many thanks & big respect to BlackmoreOPS for their brilliant guide which I have personally used many many times!)

TERMINAL/BASH IMAGES WILL BE ADDED TO THIS GUIDE SHORTLY!

(ie: the next time I install Kali GNU/Linux)

A non-root user account is a good idea for a number of reasons (installing Chrome, install and run other applications without root privileges etc).  For some reason, Kali Linux only creates a root or administer account during the installation.  For whatever reason, here is a guide to creating a non-root user account in Kali GNU/Linux.

Check the version of Linux installed by using the shell with the following commands

uname -a
lsb_release -a

Now add the user, changing the ‘username‘ to whatever you desire your user to be called:

useradd -m username

The ‘-m’ argument creates a home directory for the user at /home/username for example.

Now set the password:

passwd username 

…and type the desired password twice.

Next, add the new user to the sudo group:

usermod -a -G sudo username 

…’-a’ means ‘add’ and ‘-G’ directs to the specified group/groups (in this case the administrators or ‘superuser group’).

..and finally, alter the default shell of the newly created user to BASh (Born Again Shell):

chsh -s /bin/bash username 

…’chsh’ means ‘change the login shell’, while ‘-s’ is the desired shell for the new “non-superuser-by-default” account ( /bin/bash of course).

Creative Commons License

This work is licensed under a

Creative Commons Attribution-ShareAlike 3.0 Unported License.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s