File permissions and file ownership
The first basic command that I learned to modify permissions and file ownership in unix files is thecommand chmod. What is the function of chmod? Let us ask the unix first. In your terminal type: whatis chmod.For sure it will display to you that chmod is 1) chmod (1) – change file mode bits. 2) chmod (2) – change permissions of a file. With chmod, you can manipulate your files-- to allow them to be viewed, accessed or any other manipulations from other users. An example from the lab2 exercise would be a very good example in explaining how to use the chmod and what does it actually do. Go to your public_html folder (I assume that you already have this and including the index.html file). Type chmod ugo -rwx index.html – this will modify the permissions to access the file named index.html. Now open up a browser and locate to drdoom/~yourusername/ - this will display FORBIDDEN telling you that you do not have permission to access /~username/index.html. To make it available in your public_html folder just type again chmod ugo+rwr index.html. But remember, this will also allow some other users to edit the contents of this file. To allow only reading, instead of typing +rws you can just type +r to allow only reading. Here's a further explanation about permissions.
- +r →refers to allow reading
- +w →refers to allow writing
- +x → allows executing
- -r → disallows reading
- -w → disallows writing
- -x → disallows executing
Pipes
Pipes are used to connect the results of the first command to result of the other command. For example in you terminal. Type cd public_html and then type ls | grep a. The result will be a list of contents inside your public_html folder that has the letter a on it.
maning_e@doombot:~$ ls | grep a
programs
status
Redirections
This will redirect results of your command. A very easy example is this. When you use ls -l this will produce the list of contents inside that folder which has the permissions listed in the first. Let's redirect these results to a txt file. Type ls -l > out.txt, notice that there is no results shown after the ls -l command, it's because the results where redirected to the txt file out.txt. Type less out.txt to see the results.