≡ Menu

root directory

Find Command Exclude Directories From Search Pattern

How do I exclude certain directories while using the find command under UNIX or Linux operating systems?
[click to continue…]

Sysadmin because even developers need heroes!!!

HowTo: Linux / Unix Move Directory Up One Level

I would like to move a directory one level up into the root directory. I’ve all html files located in /home/apache2/www/html directory, and I’d like to move /home/apache2/www/html to one level up at /home/apache2/www/. How can I accomplish this over the ssh session?
[click to continue…]

Understanding Linux / UNIX Relative Pathname

Q. Can you explain the term relative pathname under UNIX or Linux oses?

A. The relative pathnames are opposite to absolute pathname. A reative pathname does not begin with a slash ( / ). Generally you specifies location relative to your current working directory. This is most useful to short a path name. For example if your current working directory is /home/tom and if you would like to change directory to /home/tom/docs/bio you can enter command cd docs/bio instead of cd /home/tom/docs/bio .

So you can use a relative path name as a shortcut to the location of files and directories.

Relative pathname example

To refer to a file in a subdirectory of the current working directory, use the name of the subdirectory followed by a slash (/) and the name of the file. For example, to display a file called foo.text in a subdirectory called bar that is located in the current directory /home/tom, enter:
$ pwd


Now, enter the command:
$ cat bar/foo.txt

.. directory name

To refer to a file in the parent directory of the current directory, use “../” followed by the name of the file. For example,if you are in /home/tom/bar and would like to display /home/tom/file.txt use pathnane ../file.txt:
$ pwd


Now, enter the command:
$ cat ../file.txt

Home-relative pathname with tilde (~)

The tilde character (~) can be used to refer to your home directory, For example, the pathname ~/file.txt refers to a file named file.txt in your home directory /home/tom/file.txt.
$ pwd


Now, enter the command:
$ cat ~/file.txt

UNIX / Linux: Absolute Pathnames

Q. Can you explain the term absolute pathname under UNIX or Linux oses?

A. An absolute pathname, is the location of a filesystem object relative to the root directory. All absolute pathnames always begin with a slash (/). With Absolute pathname you have access to complete file system objects such as directories and files.

Absolute Pathnames

You can use absolute pathnames to specify full file path such as /etc/passwd. It is believed that UNIX pathname looks and feels like Internet addresses, thus result into compatibility. The absolute pathname of the current directory can be found by using the pwd command:

Absolute Pathnames Examples

Try following commands:
ls /etc
ls /usr/share/games
cd /usr/share/games
cd ~
cat /etc/passwd
cp /etc/passwd /tmp
cd /tmp
cat passwd