Linux: Terminal Commands

Search Good guide

SSH connection

Check for existing SSH keys

ls ~/.ssh

If you allready have key pair

ssh-keygen -R

Generate new SSH keys

To generate new SSH keys enter the following command (Choose a sensible hostname such as @ where we have used ):

ssh-keygen -t rsa -C eben@pi

You can also use a more descriptive comment using quotes if you have spaces, e.g. ssh-keygen -t rsa -C “Raspberry Pi #123”

Upon entering this command, you’ll be asked where to save the key. We suggest you save it in the default location (/home/pi/.ssh/id_rsa) by just hitting Enter.

You’ll also be asked to enter a passphrase. This is extra security which will make the key unusable without your passphrase, so if someone else copied your key, they could not impersonate you to gain access. If you choose to use a passphrase, type it here and press Enter, then type it again when prompted. Leave the field empty for no passphrase.

Now you should see the files id_rsa and in your .ssh directory in your home folder:

ls ~/.ssh
authorized_keys  id_rsa  known_hosts

The id_rsa file is your private key. Keep this on your computer.

The file is your public key. This is what you put on machines you want to connect to. When the machine you try to connect to matches up your public and private key, it will allow you to connect.

Take a look at your public key to see what it looks like:

cat ~/.ssh/

It should be in the form:


Copy your public key to your device

If your Pi does not have an .ssh directory you will need to set one up so that you can copy the key from your computer.

cd ~
install -d -m 700 ~/.ssh

To copy your public key to your Raspberry Pi, use the following command to append the public key to your authorized_keys file on the Pi, sending it over SSH:

cat ~/.ssh/ | ssh <USERNAME>@<IP-ADDRESS> 'cat >> .ssh/authorized_keys'
cat ~/.ssh/ | ssh pi@ 'cat >> .ssh/authorized_keys'
cat ~/.ssh/ | ssh pi@ 'cat >> .ssh/authorized_keys'

Make bash script runable

Give execute permission to your script:

chmod +x /path/to/

And to run your script:


Since . refers to the current directory: if is in the current directory, you can simplify this to:



Mount view

Type the df command shows more human readable output:

df -aTh

OR then

mount -l


umount /media/pi/usb

Disc space

df -h
ls -l --block-size=M

Wifi and Network

sudo iwlist wlan0 scan | grep ESSID

Find LAN devices (works with OSX Terminal)

system("arp -a")


Give permission to testuser:testuser to dir

sudo chown -R testuser:testuser /var/www/test/public_html


system("rsync -arv --delete ~/folder/ ~/temp/")

Remove directory

and all it content

rm -rf directoryname

Copy files system to ssh

sudo cp filelocation pi@verkkovadelma:/home/pi

Connecting smb-services

View client shares

smbclient -L

Connect to share

smbclient \\\\\\public

FTP services

Guide for ftp Mount

curlftpfs -o allow_other ftp-user:ftp-pass@my-ftp-location.local /mnt/my_ftp/

User account and groups

Grant normal user to have permission to use GPIO.

sudo adduser my_new_user gpio

Add user to group

usermod -a -G GROUP USER

Remove User from Group

sudo gpasswd -d USER GROUP

Locales problemos

Getting away locale problems


You can fix the issue by setting the locale to en_US.UTF-8 for example:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

Once you run the last command a dialog will appear to let you choose the desired locale.

Power options


sudo reboot


sudo poweroff



Top10 commands

ps aux | grep apache2

How to check Kernel version?

uname -a
uname -v

How to check ip address?

ip addr show
ip addr show wlan0

How to check disk space used?

df -ah

How to check process status?

service udev status
systemctl status udev

How to check folder size?

du -sh brootbot/

How to check what ports are being used?

netstat -tulpn

How to check CPU usage of certain process?

ps aux | grep apache2

How to mount drive?

ls /mnt
mount /dev/sd2 /mnt/ab

How to check existing mounts?


Mount file in boot, what file you would looking?

less /etc/fstab

How to find answer for commands?

man <command>
man ps