Question
12. mkdir - create a directory a. Type mkdir firstdir. It creates a new directory called firstdir. You can also create multiple directories and also
12. mkdir - create a directory a. Type mkdir firstdir. It creates a new directory called firstdir. You can also create multiple directories and also nested directories b. Type mkdir dir1 dir2 dir3. It creates 3 directories in present directory. c. Type mkdir p dir11/dir22/{dir33, dir44}. It creates 4 directories: dir11, dir22 inside dir11, dir33 and dir44 inside dir22. d. Type ls Linux Basics and Capabilities Lab 13. rm - delete a file or directory type rm r dir3. You can also use rmdir but it only deletes empty directories 14. touch - create empty file(s) Type touch file1 file2 file3. 15. mv - move or rename files and directories a. Type mv file1 dir1 - this moves (cut and paste) the file file1 to the directory dir1. b. Type mv file2 file22. c. Type ls. 16. cp - copy files and directories Type the following commands in the order shown below: touch file4. Creates a file with the name file4. mkdir dir4 . Creates a directory dir4. cp file4 dir4. Copies file4 to dir4. mkdir dir5. Creates another directory dir5. cp -r dir4 dir5. Copies dir4 to dir5. Q6: Why do we have to use -r option to copy directories? (Hint: Use man cp.) 17. find - to find files and directories. Type find /root name file1. Q7: What is the result? (Show the screenshot.) You are searching for the file with name file1 in the directory /root. This command will search for the file in /root and in all its subdirectories. You gave /root as search location as you think file1 must be somewhere in it. If you have no information where the file might be in your system, you should start searching for it from the most top directory in the filesystem, that is /. In this later case, the command should be find / -name file1. 18. The absolute path of a file or directory is its path written from the root of the file system. For example, consider the directory dir44 you created earlier in Step 5. Its absolute path is /home/euid/dir11/dir22/dir44. 19. The relative path of a file or directory is its path from the current directory. Now, you are in your home directory which is /home/euid. The relative path of dir44 from this directory is dir11/dir22/dir44. One writes the relative path starting from a directory one level below, i.e., dir11 in our case. Linux Basics and Capabilities Lab 20. One can refer to a file or directory either using relative or absolute path (both are possible). Type touch /home/euid/dir11/dir22/dir44/file44. (Replace username you actual username). Type dir11dir22/dir44/file55 Either way you are able can access dir44 Note: When using the relative path, one should be aware of the current directory. In the above example, when the current directory changes to home, then the relative path to dir44 changes to euid/dir11/dir22/dir44. File Compression and Archiving 21. To compress and archive files: In Linux file compression and archiving (grouping file together) and compression are two different activities. First, we archive multiple files with tar command. A file with .tar extension is created. Then we zip (compress the file) with gzip command. (gzip- stands for gunzip is compression tool in linux. Bunzip (bzip2) and zip are other commonly used compression tools) a. Type touch a b c d. Creates 4 files a, b, c and d. b. tar cf compressed.tar a b c d. We are creating a tar file compressed.tar from the files a, b, c and d. c. gzip vf compressed.tar. This should create a file compressed.tar.gz. Note: For tar command, you should supply output filename along with .tar extension. For gzip, it automatically creates a zipped file with .gz extension. You no longer have .tar file after you compressed it with gzip. d. You can also do it in single step which is usually the preferred way: type tar zcvf compressed2.tar.gz a b c d. 22. To extract and uncompress files: a. Type rm rf a b c d. Deleting the files. b. Type ls. c. Type gzip dvf compressed.tar.gz you will get the file compressed.tar. d. Type tar xvf compessed.tar. You will get the original files a, b, c and d. e. Type ls. f. As before, you can uncompress and extract the compressed2.tar.gz in a sigle step: Type tar zxvf compressed2.tar.gz. Linux Basics and Capabilities Lab Getting help with the man command The man command is used to get help for any command in Linux. man stands for manual. To pull up a man page of a command, type man command. Ex: man ls. This command displays list of options available with the command. Man pages explain different options and syntax of a command and are usually difficult to understand for beginners. If you want to know usage and example for a command, google is the best place to look. Type q to quit from man page. Section 3: File Permissions and Access Control In Linux a file has read, write and execute permissions. And permissions are assigned to users of three categories: owner, group and others. The user who creates a file will be the owner, group is group of users who has access. Others are all the users other than owner and users in the group. 1. Understanding file/directory permissions: Type ls l filename to list the file permissions. The below figure explains the file details displayed. Each file (and directory) has associated access rights, which may be found by typing ls -l. Also, ls - lg gives additional information as to which group owns the file (beng95 in the following example): -rwxrw-r-- 1 ee51ab beng95 2450 Sept29 11:52 file1 In the left-hand column is a 10 symbol string consisting of the symbols d, r, w, x, -, and, occasionally, s or S. If d is present, it will be at the left hand end of the string, and indicates a directory: otherwise - will be the starting symbol of the string. Linux Basics and Capabilities Lab The 9 remaining symbols indicate the permissions, or access rights, and are taken as 3 groups of 3. The left group of 3 gives the file permissions for the user that owns the file (or directory) (ee51ab in the above example); the middle group gives the permissions for the group of people to whom the file (or directory) belongs (eebeng95 in the above example); For every user in Linux, a group with the same name is also created. This group will be default group on newly created files. the rightmost group gives the permissions for all others. The symbols r, w, etc., have slightly different meanings depending on whether they refer to a simple file or to a directory. 2. Access rights on files. r (or -), indicates read permission (or otherwise), that is, the presence or absence of permission to read and copy the file w (or -), indicates write permission (or otherwise), that is, the permission (or otherwise) to change a file x (or -), indicates execution permission (or otherwise), that is, the permission to execute a file, where appropriate 3. Access rights on directories. r allows users to list files in the directory; w means that users may delete files from the directory or move files into it; x means the right to access files in the directory. This implies that you may read files in the directory provided you have read permission on the individual files. So, in order to read a file, you must have executed permission on the directory containing that file, and hence on any directory containing that directory as a subdirectory, and so on, up the tree. Some Examples: -rwxrwxrwx a file that everyone can read, write and execute (and delete). -rw------- a file that only the owner can read and write - no-one else can read or write and no-one has execution rights (e.g., your mailbox file). 4. Changing access rights (i.e., permissions) on a file a. chmod (changing a file mode): i. Only the owner of a file can use chmod to change the permissions of a file. The options of chmod are as follows Symbol Meaning Linux Basics and Capabilities Lab u user g group o other a all r read w write (and delete) x execute (and access directory) + add permission - take away permission ii. type touch access (to create a file called access). iii. type ls l access. iv. To remove read write and execute permissions on the file access for the group and others type sudo chmod go-rwx access. This will leave the other permissions unaffected. v. To give read and write permissions on the file access to all, type sudo chmod a+rw access. b. chgrp-this command is used to change the group of a file i. Type sudo chgrp euidnew access. This will change the default group on file access to euidnew from your current username. ii. Type ls l access. c. chown- this command is used change ownership of a file or directory. This can also be used to change the group like chgrp. i. Type touch own_file. ii. Type ls l own_file. iii. Type sudo chown euidnew own_file. This change owner of the file to euidnew from you. iv. Type mkdir own_dir. v. Type ls ld own_dir. The ld option displays properties of directory. If you only use l it shows properties of contents of own_dir. vi. Type sudo chown euidnew:euidnew own_dir. This changes both the owner and the group to euidnew on folder own_dir. vii. Type ls ld own_dir. Q8: Submit a screenshot of the terminal. Note: The command chown only changes the owner of a directory but not its contents. To change ownership of files and directories within a directory own_dir, along with is permissions use chown with R option. Example: sudo chown R euidnew: euidnew own_dir. Linux Basics and Capabilities Lab Section 4: Installing Software 1. To install a software package apt-get command is used in Ubuntu Linux. Type sudo apt-get update Type sudo apt-get install chromium (if this does not work, use sudo apt-get install chromium-browser.) It checks for file size to be downloaded and ask for confirmation. Type y and hit enter. This command installs Chromium web browser. Q9: Take a screenshot of the notification that installation is complete.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started