You are on page 1of 8

Module 2 Lesson 4 - Navigation and

File Management
Managing your files and directories in the command line can seem intimidating, but once you master a few
basic commands, you'll be able to navigate and manipulate your files with ease. In this module, we'll cover file
and directory manipulation, permissions, piping and redirection, and absolute and relative paths.
Navigation and File Management
Navigating File Listing Creating Directories
Directories
To list all files and subdirectories To create a new directory, use
To navigate between in your current directory, use the mkdir command followed
directories, use the cd the ls command. Add the -l flag by the desired directory name.
command, followed by the to get a detailed listing with file
directory path. Use cd .. to permissions, owners, and more.
move up one directory.
File and Directory Manipulation
Command Description

cp Copy a file or directory to a new location.

mv Move or rename a file or directory.

rm Delete a file or directory. Add the -r flag to delete


a directory and its contents.

touch Create an empty file with the given name.


File and Directory Permissions

1 File Permissions 2 Directory 3 Setting Permissions


Permissions
Permissions for files are To change permissions,
typically represented by a Directory permissions use the chmod command
three-digit octal number. follow a similar pattern to followed by the desired
The leftmost digit file permissions, but with permissions and the file or
indicates the owner's different meanings. r directory name.
permissions, the middle allows the user to list
digit the group's directory contents, w
permissions, and the allows the user to add or
rightmost digit everyone x
remove files, and allows
else's permissions. A the user to enter the
common setting is 644, directory.
which gives the owner
read and write
permissions, and everyone
else read-only
permissions.
Piping and Redirection

Piping and redirection are powerful features that allow you to combine and manipulate commands in a
variety of useful ways. Piping takes the output of one command and sends it as input to another
command. Redirection allows you to redirect input and output to and from files.
Combining Piping and Redirection

Piping and Redirection in Action

The possibilities for combining piping and redirection are nearly endless. For example, you can use piping to
sort a list of files and redirection to save the output to a file.
Absolute and Relative Paths
1 2

Absolute Paths Relative Paths

An absolute path refers to the full path of a file A relative path refers to the path of a file or
or directory, starting from the root directory. For directory relative to the current working
example, /home/user/file.txt is an absolute directory. For example, if you're currently in the
path. /home/user directory, the relative path to
file.txt in the /home/user/docs directory would
be docs/file.txt.
The Power of the Command Line
Efficiency Automation Flexibility

Once you learn the basic You can use the command The command line gives you
commands, the command line to automate repetitive more control and flexibility
line can be much faster and tasks, such as renaming files over your files and directories
more efficient than using a or resizing images. than most GUIs.
GUI to manage your files.

You might also like