I have completed steps to use Amazon Elastic Compute Cloud (Amazon EC2) to quickly create and connect to an instance of Ubunutu Linux, and I have access to the Linux command shell. What commands can I use to navigate and manage the Linux directory structure?

Note: Because there are several Linux distributions, this article focuses on managing the directory structure of an Amazon EC2 instance of Ubuntu as described in the article How can I use AWS to quickly create and connect to an Amazon EC2 Linux instance?

Linux follows the Filesystem Heirarchy Standard, which can be confusing to the uninitiated. Before executing commands to navigate the Linux directory structure, it may be beneficial to search the "images" section of any popular internet search engine for "ubuntu file system structure" for a visual representation. The commands described here are used for navigating and managing the Linux file system from a Linux command shell.

To get more information about a Linux command, use one of the following commands followed by the name of the command that you want to find additional information about:

      info <cmd> – displays general information about the command

      man <cmd> – displays detailed information about the command

To display the arguments for a particular command, type the following:

      <cmd> --help – displays arguments for the command

See the links in the Related Information section for html formatted contents of the man (manual) files for Ubuntu 14.04 and 14.10.

pwd – (print working directory) Displays your current location in the filesystem directory structure.

ls – Lists the contents of the current directory. Type ls -alt for detailed information about each file or subdirectory contained in the current directory. Type ls -a to list all files and directories without details.

cd – Changes directories. Type cd followed by the name of the directory that you want to switch to. If you need to navigate to a subdirectory of the current working directory, type the command cd followed by the entire path to the subdirectory. For example, if the working directory is currently /home, the following command changes the working directory to the /home/ubuntu/Documents directory:
     cd ubuntu/Documents
     Note: The cd command requires case-sensitive input.

To change the working directory to the directory one level above the current directory, use the following command:
     cd .. (Note the space between cd and ..)

mkdir – Creates a new directory. For example, the following command creates a directory named spreadsheet as a subdirectory of the current directory:
     mkdir spreadsheet

mv – Moves or renames files or directories. For example, the following command changes the name of the directory spreadsheet to spreadsheets:
     mv spreadsheet spreadsheets

The following command moves the file test from the current directory to the /Documents/spreadsheets directory:
     mv test /Documents/spreadsheets

rmdir – Removes empty directories. For example, the following command removes the spreadsheets subdirectory of the Documents directory if the spreadsheets directory is empty:
     rmdir Documents/spreadsheets

rm – Removes files and directories, including directories containing files or subdirectories when using the appropriate command option. For example, the following command removes the Documents/spreadsheets directory and any files or subdirectories in the spreadsheets directory:
     rm –r Documents/spreadsheets

Linux, command shell, bash, directories


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center.