What are some basic UNIX commands?

A command is an instruction to the computer, which it interprets to perform a specific task. Most commonly a command is a directive to the command-line interface such as Shell.

Print Working Directory pwd

If you want to know the directory that you’re currently working in, use pwd command.

Let’s run this command on the shell:

pwd

Listing Files ls

If you want to see the list of files on your UNIX or Linux system, use the ls command. It displays the files/directories in your current directory. Here the current directory is usercode.

Let’s run this command:

ls

Change Directory cd

If you want to change the current working directory, use the cd command. cd .. command can be used to move back into the parent directory. We can use this command, again and again, to get all the way back to the root directory.

cd ..
ls

Now to get back to usercode directory, we’ll change the directory to usercode.

cd usercode
ls
pwd

Make Directory mkdir

To add a new directory to your current directory, use mkdir command. Let’s add test directory to our current directory:

mkdir test
ls

Remove File rm

If you want to remove a file from your current directory, use rm command. Let’s remove the main.sh file which is already present in usercode directory:

rm main.sh
ls

Manual man

If you want to know about the manual of specific command, use man followed by that command’s name. Let’s run this command for manual of mkdir:

man mkdir

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved