Some useful Linux terminal commands. Some may be specific do Debian based systems (Ubuntu, Raspberry Pi OS, etc).
cd change directory (/~ is home directory)
ls list files and directories
ls -l show details
mkdir <name> create directory
rmdir <name> delete empty directory
mv <name> move or rename file or folder
rm <name> delete file
rm -r <name> delete directory and all files and directories within
chmod -R 755 /path/to/dir Change file permissions (full permissions) to all files and directories in dir.
-R for recursive
xxd filename display a binary file in hex format
xxd | head -5 or
xxd | tail -5 view the first 5 lines or last 5 lines of hex
Creating File System Symbolic Link (symlink)
A symlink can be used to create a file system link to a directory. For example on Windows WSL to link a windows folder to a directory in the user’s home directory in Linux:
ln -s "/mnt/c/Users/[username]/Documents/MyFolder" ~/MyFolder
Creating an ISO (CD) image from a directory
ISO image files can be useful for archiving data or creating a virtual CD which can be mounted in a Virtual Machine. To create an ISO image in Linux use the mkisofs program:
mkisofs -V 'Volume Label' -o <filename>.iso '/path/to/directory' for example:
mkisofs -V 'Useful Programs' -o myprograms.iso '/home/john/useful programs'
ssh user@hostname log in to PC at hostname with username user. hostname can also be an IP address
scp sourceuser@sourcepc:filepath1 destinationuser@destinationpc:filepath2 file transfer via network. sourceuser@sourcepc: can be omitted if you are currently logged into sourcePC.
ps aux list all processes
strace -p1234 -s9999 -e write view output from process with ID 1234
kill <pid> Terminate process PID. PID can be found using
ps aux or
Find Operating System Version
To find the operating system release version use:
Autostart Script on Boot
UPDATE – The below method is depreciated but will still work on some systems due to backward compatibility (e.g. Raspberry Pi).
If you need a script to be run every time the machine is booted, the best way to do this is to use the rc.local file:
sudo nano /etc/rc.local
At the bottom of the file add the command to start your script, for example:
python /home/pi/my_script.py &
Note that all commands are executed at root privileges and therefore there is no need to add
sudo to the command. Also note that if your script runs continuously you will need to add and ampersand at the end of the line so that a new process is created. Otherwise the machine will get stuck on the script not finish booting.