1 | 2 | 3 | 4 | 5 | page 6 | 7 | 8 | 9 | 10 | 11
Linux file name notation. Linux file system is organized as hierarchies of directories (also known as directory trees). To reach the location of a file within an arbitrary directory, a file path must be specified. There are two basic types of paths: relative paths and absolute paths. A relative path is the location of a file relative to the current directory. The command pwd shows the current directory (the directory in which the user is currently working).

An absolute path, also referred to as an absolute pathname or a full path, is the location of a file relative to the root directory (/). Absolute paths always begin with the root directory. Because the root directory is represented by a forward slash ( / ), a path is absolute if the first character is a /. Otherwise, it is a relative path.

Forward slashes are also used to separate all items in both relative and absolute paths. When a path ends with a forward slash, it indicates that the last item in the path is a directory.

A file can be located by either absolute or relative paths. Absolute paths start at the top of the file system with / (referred to as root) and then look down for the requested directory. Relative paths look down from the current directory.

Using absolute paths allows you to change to a directory from the / directory, which requires you to know and type in the complete path. Using relative paths allows you to change to a directory relative to the one you are currently in, which can be convenient if you are changing to a subdirectory within your current directory.

The following commands perform file and directory management functions in a Linux environment. You definitely will use one or more of these commands to manage a dedicated server remotely. You should become familiar and eventually proficient with these commands since you may have to use them on a daily basis.

You can learn these commands to see how they work by actual practice with simple parameters first. Detailed help is available by typing man and the name of the command. For example man cat shows the help file for cat which explains all of its command line options. There are plenty of good examples on how to use these commands from the Internet. Remember that the search engine is your friend.

In general, you probably will not use all options available in a particular command. However, if you are well aware of what these commands can do, it would make the task of administration a dedicated server simpler, more efficient and secure. If you develop server scripts, understanding these commands well will reduce the development time of your project.

Linux commands to manipulate files in the file system
Command Description
cat cat anyfile sends the content of the file anyfile to standard output (your terminal window or ssh session). If the file is large or is a binary file, use Control C to break out the display stream.
cd Enter directory. Typical cd commands are following:
  • cd returns you to your login directory.

  • cd ~ is same as cd (without any arguments)

  • cd / takes you to the entire system's root directory at the top of the directory tree.

  • cd /home takes you to the home directory, where user login directories are usually stored.

  • cd /root takes you to the home directory of the root user, or superuser, account created at installation; you must be the root user to access this directory.

  • cd .. moves you up one directory.

  • cd ~otheruser takes you to otheruser's login directory, if otheruser has granted you permission.

  • cd /absolute/path regardless of which directory you are in, this absolute path would take you straight to path, a subdirectory of absolute.

  • cd ../../dir3/dir2 this relative path would take you up two directories, then to dir3, then to the dir2 directory.
  • chgrp Change the group ownership of a file to newgroup. For example, chgrp newgroup anyfile.
    chmod Change access permissions of a file. Read, write, execute access rights can be modified for user, group, others.
    For example, chmod ug+rw anyfile.
    Remember, only the owner of a file or directory can set its permissions. Use ls -l to find the owner. Otherwise, login in as a root user (su) and then setup permissions using chmod.
    chown Change file owner and group ownership. For example, chown newuser:newgroup anyfile.
    1 | 2 | 3 | 4 | 5 | page 6 | 7 | 8 | 9 | 10 | 11