Want to start leveling up your terminal skills? The Linux command line has a wealth of flexible commands for file management. Learn how to use the most common ones for your everyday tasks.

1pwd

When you’re using the command line, you’re always “in” a specific directory. Linux calls this the working directory. By default, your prompt—the text before your cursor on each line—will display the name of this directory. It’s usually your home directory when you first open a terminal.

The pwd command stands for “print working directory” and you can think of it like a “you are here” marker. When you run pwd, it tells you the full (absolute) path of your working directory:

The linux pwd command showing the current directory is “/usr/local/bin."

2cd

Now you know where you are, it’s time to learn how to move around your filesystem withthe cd command, which stands for “change directory.” Your working directory is important because all commands and files that use relative paths do so from that directory.

Run the cd command by supplying a directory as the first argument. This directory can be a complete absolute path:

The linux cd command changes the current working directory, confirmed by pwd.

Or it can be relative to your current directory:

you may call cd without any arguments to quickly return to your home directory:

3ls

Once you’ve navigated to a directory, you’ll often want to know what files (including subdirectories) it contains.The ls command stands for “list"and, unlike the previous two commands, it has many options.

Use ls on its own to show the contents of the current directory:

The Linux cd command showing examples with absolute and relative paths.

You can list specific files or directories by passing them as arguments. Use the -l flag (long format) to display one file per line with full information including permissions, ownership, size, and modification date/time:

This format also displays the type of each file. If the first letter of the permission string is a “d”, it’s a directory. If it’s an “l”, it’s a link. If it’s a “-”, it’s a regular file.

The Linux cd command with no arguments changes directory to the user’s home.

If you want a more obvious indicator, try the -F option. It adds a “/” to the end of directories and an “@” to the end of links, making them easier to spot:

Note that you can include wildcard characters to list files matching a pattern. You canuse wildcardswith any command that accepts file arguments, not just ls.

The linux fs command displaying a set of files in two rows and five columns.

4touch

This strange-sounding command lets you update a file’s access & modification times. You might not think you’d need this much, and you’re probably right, buttouchhas a secondary purpose: to create an empty file.

Run the command with any number of arguments, then touch will update existing files and create new ones:

The ls command showing a list of files, one per line, each with metadata like permissions, owner, and modification date.

5mkdir

To organize your filesystem, you’ll want to create directories to group related files. Remember that directories can contain subdirectories, and so on. The mkdir command is simple: it creates a directory at the path of each argument you supply.

Note that each path can be relative or absolute. If you try to create multiple levels of directory at the same time, mkdir will complain:

The Linux ls command with the -F option which adds a “*” at the end of executables and an “@” at the end of links.

Use the -p flag to create the full hierarchy in one go:

6cp

To create an additional copy of an existing file, use the cp (copy) command. In its simplest form, give the path of an existing file and a path for the new copy:

You can also use this command to copy several files to a directory. To do so, use as many file arguments as you like, followed by a single directory:

The touch command creating a new file, then updating its modification time, confirmed by an ls.

7rm / rmdir

Eventually, you’ll find you’ve created too many files and you’ll want to get rid of some. Enter rm, short for “remove.”

The rm commandtakes one or more files as arguments and will attempt to delete each one:

The Linux mkdir command creating three directories, including one subdirectory.

Use the -f option to “force” removal of a file. This attempts to delete a file, even if its permissions appear to restrict you from doing so:

For example, without write permission, you’ll be prompted for confirmation if you attempt to delete a file. The -f flag skips this step; it also suppresses an error message if the file doesn’t exist.

The Linux mkdir command showing an error when trying to create a deep subdirectory.

rm will also let you remove directories, but not by default:

The -d option will let you do so, as will rmdir:

8mv

Initially, it might seem like the mv command (short for “move”) has a dual-purpose: both renaming files and moving them from one directory to another. However, Linux considers both just ways of changing a file’s path.

With two arguments, mv will rename—or move—the first to the second:

mv has another mode that works a bit like cp’s second mode. If the final argument is a directory, mv will move all other named files into that directory, even those that are directories.

9chmod

On Linux,each file has a set of permissionsdescribing who can access it and what they can do with it. The “who” can be the owner of the file, anyone in the same group as the file, or anyone at all. That “what” can be reading, writing, or executing—running the file as a program.

Use of chmodis a bit complicated because of its permissions syntax. Basic use is like this:

An example of permissions is “go+r” which makes (+) a file readable (r) to users in its group (g) and other users (o). Another typical use is to make a file executable:

This lets you run a script on the command line by typing its path.

10ln

Links let you reference filesin more than one place on the file system, without taking up much extra space. The symbolic—or soft—link is the easiest to understand:

The link command creates a link that references an original file:

Without the -s option, you’ll create a hard link, which acts more like a second copy of the original file. They are a bit harder to understand and, therefore, are less commonly used.

There aremany more important Linux commandsyou should learn to do anything from killing a process to fetching a remote web page.