Most of you will know how to navigate directories using the cd command and how to create a directory with mkdir. You will also be familiar with the mv command. The mv command is not just for moving files from one directory to another; it can also be used to rename files like this.

mv oldfilename.txt newfilename.txt

In order to list files and directories in the current folder you are in, you may use the ls command.

You can also list files and folders not in your current working directory by providing the directory path with commands like this.

ls /home/John
# to list with more details of files
ls -l /home/John
# to list all files, including hidden files
ls -la /home/John

If you look up the ls command using man ls, you will see that you can pass a lot of options. One of the useful ones is the -t option to sort the files in ascending order of time. For example, if you want to see the latest modified file at the top of the list, use the command below.

ls -t

The ls command sometimes lists a long list of files and directories, but what if you want to filter out files based on the name, time, or some other criteria ? To search through files, one can use the find command.

# finds files in the specified folder with extension .txt and which are newer than the date 2025-01-01
find /home/John -type f -name *.txt -newermt 2025-01-01

There is also an option to execute commands on results using -exec.

Use man find to see the full list of options.

A quick way to find the path of a file or directory is by using the locate command.

locate *.txt

Exploring the manual pages with man can reveal additional options for each command. Familiarizing these tools will enable you to navigate your operating system effectively.