So, your team lead or boss has asked you to SSH into a Linux box at work and it’s your first time. You’ve gone ahead and googled how to use PuTTY and are in a secure shell session. Now what? You’ve used Command Prompt a couple of times, but nothing has prepared you for this. You’ve tried typing in
dir to see what is in the folder you’ve landed in, and it’s worked. You try the trusty ol’
cd C:\ and ERROR. Why am I doing this? Linux is for basement dwellers who have been using a computer longer than you’ve been alive, it’s a scary place. Wrong! You’re a fellow geek/nerd and you can do this.
While Windows uses the
\ as a directory structure delimiter Unix based operating systems use
/. Where C:\ would usually be the root of your main OS drive in Ubuntu and other Linux distributions
/ is the root directory of everything on the machine.
cd / in Linux is kind of (but not really) the equivalent of
cd C:\ in command prompt. Have a look at this video to getting a quick 100s overview of the Linux file system structure. You’re now in the root directory, we’ve established earlier that in Ubuntu
dir will show you the contents of the directory. In Unix based OSs we use
ls to list contents.
In most terminal applications you can apply “flags” to your operations, this is no different to the
ls command. To this we could add
ls -l to show the directory contents in a list, or single line per item in the directory.
-a will show you hidden files/folders in the directory too. There are many other “flags” that we could apply to
ls, to see them all as well as an over view of the list contents we can use
man [program] in the Unix terminal followed by the program you specify will open up the “manual” for that program.
When you’re in your terminal you will see the blinking cursor following
user@host: directory$. To break this down the user is the user that is logged into the system, the host is the system that you’re on, and directory is where you are currently in the file system.
~ is the “home” directory for your current user.
pwd or “print working directory” will output the full path to where you are currently located in the filesystem.
cd ~ will take you to your home directory