Lesson 2: Working with Directories in Unix
In this lesson we will look at Unix commands that allow us to navigate/create and remove files and directories. Firstly we will look at the LS command.
Note: Ignore the % this is just what your command prompt display should look like.
When you first login, your current working directory is your home directory to view the contents of your home directory you would type ls.
The ls command lists the files in the current workind directory, note ls on its own does not list hidden files as these contain important configuration information.
To list these files you have to add the option –a
So try typing ls -a
Other options would be
% ls -al
This command provides a long listing of information about all files in the current directory
% ls -al /usr
This command lists long information about all files and folders in the "/usr" directory.
To find out more about ls try using the man command.
The man command display help information about each command.
For Example:
% man ls - this will display help information for using ls in unix.
% man mkdir – will display help information for creating directories.
ls also lends itself quiet well to recursively listing file and directories using *. Example we want to display all files that end with .dat then we would type something like
% ls *.dat
% ls pas* - list all file that begin with pas