Posts

Moving Files

The  mv  command is used to move a file from one location in the filesystem to another. mv SOURCE DESTINATION The  mv  command requires at least two arguments. The first argument is the source, a path to the file to be moved. The second argument is the destination, a path to where the file will be moved to. The files to be copied are sometimes referred to as the source and the place to where the copies are placed in is called the destination. Follow Along Use the following command to switch to the  Documents  directory: sysadmin@localhost : ~ $ cd ~/Documents To move the  people.csv  file into the  Work directory, use the filename as the source, and the directory name as the destination: sysadmin@localhost : ~/Documents $ mv people.csv Work If a file is moved from one directory to another and without specifying a new name for the file, it will retain its original name. The move above can be co...

Changing File Ownership

Initially, the owner of a file is the user who creates it. The  chown  command is used to change the ownership of files and directories. Changing the user owner require administrative access, a regular user cannot use this command to change the user owner of a file, even to give the ownership of one of their own files to another user. However, the  chown  command also permits changing group ownership, which can be accomplished by either root or the owner of the file. To change the user owner of a file, the following syntax can be used. The first argument  [OWNER]  specifies which user is to be the new owner. The second argument  FILE  specifies of which file the ownership is changing. chown [OPTIONS] [OWNER] FILE Follow Along Use the following command to switch to the  Documents  directory: sysadmin@localhost : ~ $ cd ~/Documents Currently all the files in the  Documents  directory are owned by the  sysadmin...

Changing File Permissions

The  chmod  command is used to change the permissions of a file or directory. Only the root user or the user who owns the file is able to change the permissions of a file. Consider This! Why is the command named  chmod  instead of  chperm ? Permissions used to be referred to as  modes of access , so the command  chmod  really means  change the modes of access . There are two techniques of changing permissions with the  chmod  command:  symbolic  and  octal . The symbolic method is good for changing one set of permissions at a time. The octal or numeric method requires knowledge of the octal value of each of the permissions and requires all three sets of permissions (user, group, other) to be specified every time. For the sake of simplicity, only the symbolic method will be covered. (at least for now) Follow Along Use the following command to switch to the  Documents  directory: sysadmin@local...

Permissions

Permissions determine the ways different users can interact with a file or directory. When listing a file with the  ls -l  command, the output includes permission information. For the example we will use a script called  hello.sh  located in the  Documents  directory: Follow Along Use the following command to switch to the  Documents  directory: sysadmin@localhost : ~ $ cd ~/Documents sysadmin@localhost : ~/Documents $ ls -l hello.sh -rw-rw-r-- 1 sysadmin sysadmin 21 Aug 1 02:35 hello.sh Below is a review of the fields relevant to permissions. File Type Field - rw-rw-r-- 1 sysadmin sysadmin 21 Aug 1 02:35 hello.sh The first character of this output indicates the type of a file. Recall if the first character is a  -  this is a regular file. If the character was a  d , it would be a directory. Permissions Field - rw-rw-r-- 1 sysadmin sysadmin 21 Aug 1 02:35 hello.sh After t...