Lab 4

For each of the following commands write a description of what it does and provide a screenshot with an example of its usage:


chmod – changes the mode or permissions of a file or directory

In the Picture below, you will see a text file called GM in the home folder. When you open the file, you will see the word “Hello” in the text.

GM1

 

When you open the terminal screen and type the command ‘chmod 000 GM’. This command will apply changes to the file GM. 000 is the permission that will be set on the file. 000 is define as not having the privilege to read, write or execute. You will notice the the file ‘GM’ will have a lock . This file is now locked. No one has read, write or even open the file. If you try to open the file, a pop-up screen will appear saying “Access Denied”. The only way to have any privilege to this file, you must go to the terminal and change the permissions to that file.

GM2


su – command allows you to log in as another user.

On the terminal, type the following command, ‘su’ followed by the username of the user you are trying to log in as. For example. In my computer, when I log-in to my account and type ‘su giovanni’ on the terminal, it will immediately ask me for the password the for the user giovanni. once i enter the correct password, any changes made after that will be done under the username giovanni.

GM3


sudo – allows you to execute commands as a different user, usually a superuser in a controlled way.

GM4


chown – command used to change the owner of a file.

in order to change the owner of a file, you must type the command “chown username file-name’ For example, if the username bob is the owner of the file GM. If, I go to the terminal and type ‘chown giovanni GM’, the username giovanni will now be owner of the file GM.

GM5


passwd – used to change the password

When you type the command ‘psswd’ in the terminal screen, it will ask you for your current password. Once you entered your current password, it will ask you to enter a new password, once you enter your new password, it will ask you to re-enter your new password. once you re-entered the new password, it will be saved. Every time a password is required for your account, you will used your new password.

GM6


ps – command usd to view snapshots of the processes.

On the terminal, type the command ‘xlogo&’ three separate times. You will notice that a logo with an X will appear on the screen for each xlogo& you entered. After that type the command ‘ps’ on the terminal. The terminal will display all processes done before enter the command ‘ps’. You will notice that each process has a process id.

GM7


kill – used to terminate a process or processes.

If you continue from the steps done in ‘ps’, you will still have three windows on the screen with the letter X. On the terminal screen type the command ‘kill all’. What this command does is will all processes. If you only wish to terminate the a specific process you will type the command ‘kill’ follow by the process id or PID found when you entered the command ‘ps’.

GM8

GM9


printenv – displays a list of the environment variable.

GM10