Useful terminal commands
In this lesson we will cover some of the basic commands in the terminal. We will learn how to list the content of a directory, create and manipulate files, print a line of text, change the working directory, etc.
One of the most commonly used commands it the ls command. This command lists the content of the specified directory. If no directory is specified, the ls command displays the content of the working directory:
To get a more detailed output, we can use the ls -l command:
The pwd command is used to print the path of the current working directory (the directory we are currently in):
The cd command is used to change the working directory. The path of the directory you would like to access needs to be specified in the command. For example, to change the working directory to /opt, the cd /opt command is used:
Note how the prompt changed to reflect the change.
The echo command is used to output text to the screen. The text that will be displayed is entered after the echo keyword:
To display the current user, the whoami command is used: