How to see the permissions and size of a directory on a Unix/Linux system
Option 2:
|
| Command | Description |
|---|---|
cd |
takes you to your home directory |
ls -al | more |
lists all of the files in your home directory,
then use the more command to page the directory listing. Then look for the
bin subdirectory. |
I've also seen a similar approach where people use the grep
command instead of the more command:
| Command | Description |
|---|---|
cd |
takes you to your home directory |
ls -al | grep 'bin' |
lists all of the files in your home directory,
then uses the grep command to search for the bin
directory in the ls -al listing. |
Option 3: ls -ld bin
In the final option you use the -d option of the ls command
so that ls won't look inside the bin directory, it just gives you a
listing of the parameters for that directory. Normally, if you type ls -al
bin you will get a listing of the bin directory parameters, but you will
also get a listing of every file in that directory, which usually scrolls the
line you want to see off the screen. The -d option tells ls not
to list the contents of the bin directory; just show us the listing
for the directory itself.
Here is the step-by-step approach:
| Command | Description |
|---|---|
cd |
takes you to your home directory |
ls -ld bin |
provide a long listing of the bin directory,
without showing the contents of the bin directory. |
Of course this also works great when you are somewhere else in the filesystem,
because then you can just issue one command as shown below to see the parameters
of the bin subdirectory of your home directory.
| Command | Description |
|---|---|
ls -ld ~/bin |
provides a listing of the bin directory
that is in your home directory, regardless of where you are in the
filesystem at the time the command is run. |
If you haven't seen it before, the "~" character
is a shortcut way of referring to your home directory.
Summary
I know this is a somewhat trivial example for some people, but hopefully you saw a few things that you haven't seen before, including:
- How to use the
-doption of thelscommand. - How to refer to your home directory using the
~shortcut. - Examples of using
more,grep, and simple pipe commands (ls -al|more, andls -al|grep 'bin') in Unix.
search page
main blog page
send feedback, suggest a topic