How to Manage Files in the Linux Terminal and Desktop

Christian Cawley 24-06-2016

Just moved to Linux? Saying goodbye to Windows in favor of an open source alternative such as Ubuntu? Once you make the change, you’ll find a sensible desktop that is easy to use, from installing new apps and launching them to organizing your data.


Managing files and folders in Linux is straightforward, whether you’re using the desktop or the command line 4 Ways to Teach Yourself Terminal Commands in Linux If you want to become a true Linux master, having some terminal knowledge is a good idea. Here methods you can use to start teaching yourself. Read More . Indeed, it can be quicker to use the Terminal input in many situations, so we’re going to take a look at what commands are available, and how they compare to the desktop, mouse-driven alternative.

The Terminal and Nautilus

As we’re using Ubuntu 16.04 LTS to look at file management in Linux, we’re going to be using Nautilus. This is the default file manager for Ubuntu, although others can be installed Thunar vs. Nautilus: Two Lightweight File Managers For Linux Is Thunar a better file manager than Gnome's default, Nautilus? Read More  (although they cannot be easily set as defaults). To open Nautilus, all you need to do is click on the file icon in the Unity Launcher.


The Terminal, meanwhile, is pretty much as you would expect it — a black box with a prompt, and a flashing cursor waiting for a command. You can find this by clicking the Ubuntu Unity button, and typing terminal. The list of results should display a command line app, so click this to open.

List Your Files with ls

In the file manager, listing files is relatively simple. Just left-click to select the drive or directory you wish to view the contents of, and they will be displayed. Opening a sub-directory will display further contents.


Similarly, it’s just as simple to view the contents of a directory in the Terminal. After you launch the command line, you’ll be defaulted to your personal directory, Home. To view the contents enter:


This lists the files in the current directory. If you want to also see the contents of any sub-directories, use:

ls -R

The -R switch indicates to the Terminal that you wish to observe a recursive list of sub-directories and their contents.



Individual directory contents can be listed, meanwhile, with ls /[DIRECTORY NAME]. So, for example:

ls /Music

…will display the contents of the Music sub-directory.

Use cd to Change Directory

In the file manager, you can click directories in the left-hand panel to quickly get an overview of what files are stored where. Each time you select one of these directories, you’re opening them, changing your position within the file management hierarchy.

The same effect is achieved in the command line using cd. For instance:

cd Documents

…will change directory to the Documents sub-directory. If you prefer, however, you can specify a full filepath to open directories elsewhere on the drive.

cd /etc/fonts

Meanwhile, you can go up a directory — that is, for example, from Documents back to Home — using:

cd ..

Also, make sure you know about cd / — this command will send you back to the default Home directory from any other.

Deleting Files and Directories

In the Terminal, file deletion is frighteningly simple; no confirmation is offered, so once you enter the command, the file is gone, for good (unless you employ recovery software The Best Ways To Recover Data On Linux No matter whether it was your fault or not, things can happen to the data stored on your devices. Hard drives, solid state drives, and removable media can all potentially "lose" files because of numerous... Read More to retrieve it.


To delete a file in the terminal, use rm, like this:

rm myfile

You can also use the full path to the file you wish to delete:

rm /path/to/myfile

The same action can be completed in the desktop environment by right-clicking the file and selecting the Delete option (in Ubuntu this is labeled Move to the rubbish bin). You can also simply select the file and hit the Delete button on your keyboard. The same is true for directories — but make sure there’s nothing inside that you need to keep!


Removing a directory in the Terminal requires the rmdir command:

rmdir mydirectory

Again, a full path specification can be included to delete a directory from another location on the directory tree:

rmdir /path/to/mydirectory

To delete a directory and its contents, use the -r condition. Again, using the command line with rm won’t offer confirmation, so use with care 9 Lethal Linux Commands You Should Never Run You should never run a Linux command unless you know exactly what it does. Here are some of the deadliest Linux commands that you'll, for the most part, want to avoid. Read More !

Move and Copy with mv and cp

If you need to move a file in the Terminal, the mv command is your friend. Simply employ it with the name of the file you wish to move, and its new directory:

mv myfile /home/mydirectory

To perform this action in the GUI, right-click the file and select Move To….

Rather than move a file, you may prefer to copy it. This is done using the cp bash command, with sudo, like this:

sudo cp myfile /home/mydirectory

You might also copy a directory and its contents with the -r recursive condition:

sudo cp -r /home/mydirectory /home/otherdirectory

This command copies the contents of “mydirectory” and drops them into “otherdirectory”.

Make Directories in the Terminal with mkdir

Creating a new directory in the Terminal is also very simple, thanks to the mkdir command (which you’ve probably guessed abbreviates the term “make directory”).

mkdir newdirectory

…will create a new directory with that name in the current location.


You can also use the command to create a directory elsewhere:

mkdir /home/mydirectory/newdirectory

On the GUI side of things, you can use the mouse-driven file explorer to create directories by right-clicking into the file browser window and selecting the New Folder option.

Command Line or Desktop?

Navigating through a computer’s directory tree is how we find the files and folders we use regularly. But one other thing is worth sharing: how to create a desktop link (known in Windows as a shortcut How to Create Desktop Shortcuts From Anywhere in Windows New to Windows? Desktop shortcuts can help you save a lot of time -- here's how to create them for any file. Read More ).

While such links cannot be used in the Terminal, they can be created, using ln -s:

ln -s /home/mydirectory/newdirectory /home/mydirectory/Desktop

Here, a link is made from the “newdirectory” folder to the Desktop, from where it can be opened. This should save you time finding important directories. You can do the same in the file manager by right-clicking and selecting Make Link.


Do you find the command line or the desktop most efficient and user friendly? Have we opened your eyes to the flexibility and power of the command line options Save Time in the Linux Terminal with These 20 Shortcuts Whether you're a terminal newbie or someone who got over the fear long ago, here are 20 shortcuts that can help you overcome some of the command line's awkwardness. Read More in Linux? Tell us about it — the comments box awaits!

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Lazza
    June 27, 2016 at 8:57 pm

    Another pro tip: assume you are looking at a folder full of stuff with Nautilus and you want to select all PDF files.

    Press Ctrl+S, type "*.pdf" and press Enter.

    • Christian Cawley
      June 28, 2016 at 6:34 am

      Great tip, thanks for sharing, Lazza!

  2. Lazza
    June 27, 2016 at 8:52 pm

    «You can do the same in the file manager by right-clicking and selecting Make Link.»

    Even better: drag the mouse in the destination where you want the link to be and hold the Alt key while doing that. Release the file (not the Alt key) and a menu will pop up. Click "link here" and you are done. :D

  3. Christian Cawley
    June 25, 2016 at 5:15 pm

    "How to Manage Files in the Linux Terminal and Desktop" :)

  4. Anonymous
    June 24, 2016 at 11:07 pm

    Any of the Terminal commands you mention can be used in ANY Linux distro that uses the bash shell, not just Ubuntu.