Chmod
Chmod
Chmod
Let's say you are the owner of a file named myfile, and you want to set its permissions so that:
This example uses symbolic permissions notation. The letters u, g, and o stand for "user",
"group", and "other". The equals sign ("=") means "set the permissions exactly like this," and
the letters "r", "w", and "x" stand for "read", "write", and "execute", respectively. The commas
separate the different classes of permissions, and there are no spaces in between them.
Here the digits 7, 5, and 4 each individually represent the permissions for the user, group, and
others, in that order. Each digit is a combination of the numbers 4, 2, 1, and 0:
So 7 is the combination of permissions 4+2+1 (read, write, and execute), 5 is 4+0+1 (read, no
write, and execute), and 4 is 4+0+0 (read, no write, and no execute).
EXAMPLES
Read by owner only
Write by anyone
Execute by anyone
Example 2 :
Let’s restrict the permission such that the user cannot search the directory EXAM.
BEFORE: drwxrwxr-x mik mik EXAM
chown command
chown command
chown command changes the user and/or group ownership of for given file. The syntax is:
Examples
In this example change file ownership to vivek user and list the permissions, run:
# chown vivek demo.txt
# ls -l demo.txt
Sample outputs:
In this next example, the owner is set to vivek followed by a colon and a group onwership is also
set to vivek group, run:
# chown vivek:vivek demo.txt
# ls -l demo.txt
Sample outputs:
In this example, change only the group of file. To do so, the colon and following GROUP-name
ftp are given, but the owner is omitted, only the group of the files is changed:
# chown :ftp demo.txt
# ls -l demo.txt
Sample outputs:
unlink syntax
unlink FILE
unlink examples
unlink hope.txt
Removes the file name hope.txt, and if there is no other hard link to the file data, the file data itself is
removed from the system.
link command
Description
The link command creates a hard link named FILE2 which shares the same index node as the
existing file FILE1. Since FILE1 and FILE2 share the same index node, they will point to the
same data on the disk, and modifying one will be functionally the same as modifying the other.
link examples
link computer.txt hope.txt
The above example would create the file hope.txt linked to the file computer.txt. Any changes
that occurred with either of these files would affect the other file or link.
Running the ln command without options creates a hardlink from source to destination. With the
help of the option -s it creates a symbolic link, instead.
Allowed within file systems only Allowed between different file systems
Symbolic links can be made to directories as well as to files on different filesystems or different
partitions.
$ ln -s /usr/bin/python link_to_python
$ ls -la link_to_python
lrwxrwxrwx 1 frank frank 15 Oct 5 14:25 link_to_python -> /usr/bin/python
How do I create soft link / symbolic link?
Soft links are created with the ln command. For example, the following would create a soft link
named link1 to a file named file1, both in the current directory
$ ln -s file1 link1
To verify new soft link run:
$ ls -l file1 link1
Sample outputs: