Assignment 3/4
command to copy a file or directory
'cp' cp ./Documents/Work/Payroll.txt ./Documents/Taxes/2019/
What is the command to add groups?
'groupadd' ex: sudo groupadd Cincinnati
What commands can get you to the first and last 10 lines respectively.
'head' & 'tail' Ex: sudo head /var/log/message sudo tail /var/log/messages
What is the command for long listing of file types
'ls -l'
Command to create a new directory
'mkdir' ex: mkdir /home/user/Documents/Taxes mkdir ./Documents/Taxes/2017
command to more or rename a file or directory
'mv' ex: mv ./Documents/Work/PartyBudget.txt ./Documents/PartyPlanning/ Let's rename the Payroll and EmployeeList files in the ./Work/Taxes/2019/ directory to specify the year in the name of the file: • Enter the following commands (each command should be one line): mv ./Documents/Work/Taxes/2019/Payroll.txt ./Documents/Work/Taxes/2019/Payroll_2019.txt mv ./Documents/Work/Taxes/2019/ EmployeeList.txt ./Documents/Work/Taxes/2019/ EmployeeList _2019.txt
command to remove a file or directory
'rm' ex: rm ./Documents/PartyPlanning/PartyLocations.txt
Command to create files that can be edited later
'touch' ex: touch /home/user/Documents/PartyPlanning/GiftIdeas.txt touch /home/user/Documents/PartyPlanning/GuestList.txt
What is the command to add users to the group you created? Also what does the options '-a' and '-G' do?
'usermod' The -a option indicates we want to "append" the user's group membership. If we forget this it will remove the user from all other groups they are a member of. The -G option indicates which secondary group we want to add the user to ex: sudo usermod -a -G Cincinnati msmith
Explain 'chmod' command
(Change mode bits) used to set permissions values. ex: sudo chmod 775 /share/Cincinnati
List and explain the file types
- (regular file): A regular file is identified with a simple 'dash'. Regular files are the most common files found in Linux and can just about any file that contains data such as text, images, binary (program) files, audio files, etc. d (directory): Directories are considered files by the OS which contain pointers to other files. l (links): Links are files that point to other files or directories. They are similar to a shortcut. c (character) and b (block): Character and block files are used to allow programs to communicate with hardware devices on the system. Block devices are generally storage devices such as hard drives or memory. These are only found in the /dev directory s (sockets): Sockets are used for communication between processes. They are also usually only found in the /dev directory.
When creating a symbolic link, which command option must you use?
-s
absolute file path
-type of file path begins at the root of the file system and always begins with a "/"? ALT:The name of a file that includes a path to the file from the root directory of a file system and includes all parent directories that the file resides in. An absolute file path always starts with a /. ex: /home/user/Document
Which directory contains configuration files used by the OS and applications?
/etc
Which directory contains settings and personal files for normal users?
/home
Which directory contains changing files, such as log files?
/var
What are the three levels of access rights
1)The owner which is either the 'root' user or creator. 2)Rights assigned to a group of users 3)Rights assigned to everyone else that has access
Using chmod, what number would you use to set the following permissions: Owner - Read and write Group - Read and write Everyone - Read
664
What keys do you use to stop following a file?
CTRL-C
In Linux, when deleting a file from the command line, you can always go back and recover it from the Recycle Bin.
False
What is a hard link
Hard links point to the physical location of a file on the Hard disk and take on the properties of the file they are linked to
How do you enter command mode when editing a text file
Shift + :
/etc/group
The file that contains group definitions and memberships.
/etc/shadow
The file that contains the encrypted (by Hash algorithm) password as well as password and account expiry parameters for each user account.
/etc/passwd
The file that contains user account information. enter command: less /etc/passwd
relative file path
The name of a file that includes a path to the file from the current working directory of a program (pwd). ex: ./Documents /home/Bob/Documents/PartyPlanning.txt >> ./Documents/PartyPlanning.txt
Explain the option '-f'
This allows you to leave the output open and display new lines as they are created. ex: sudo tail -f /var/log/messages
Explain the 'wq' command
This will "write" and "quit" the file. In other words, it saves the file and closes it
Explain the 'q!' command
This will close the file without saving in case you made a mistake. (Pronounced q-bang)
Explain 'chgrp' command
To change the group specified for a certain directory ex: sudo chgrp Cincinnati /share/Cincinnati
what does the '-c' option do
allows us to add and assign the full name of a new user in the comment field ex: sudo useradd -c "Mike Smith" msmith
Explain 'useradd' command and what file would you access to verify changes?
allows us to create additional users on the system. /etc/passwd file to verify changes ex: sudo useradd -c "Mike Smith" msmith
Explain the 'vi' command
allows you to edit configuration files.
Explain 'chown' command
change the owner of the directories ex: sudo chown msmith /share/Cincinnati
explain 'ls' command
list the contents of each directory
How to create a symbolic link example
ln -s /home/user/Documents/Work/Taxes/2019 /home/user/Documents/2019Tax To create a link, we will use the 'ln' command. To create a symbolic link, we must also use the 's' option. The format for the command is to specify the target (the file we want to link to), then the Link Name (the file name or directory name we want to create).
Which command would you use to do a directory listing?
ls
Outline and explain user file permissions
r - Read. This allows the user to read the contents of a file or list the contents of a directory. w - Write. This allows the user to edit a file or create, rename, and delete files in a directory. x - Execute. This allows a user to execute a file that contains a program/script or to enter a directory (i.e. cd /dir
If a directory contains other files how do you remove it?
recursive (r) to remove directories and files located within and force (f) so we are not prompted to verify each file to be removed. ex: rm -rf ./Documents/Taxes
What is the name of the default "super user" account creating in Linux?
root
How do you switch users (also used to help test the permissions).
su
How do you view permissions currently set
sudo ll (the directory your looking at)
How do you access and edit the "sudoers" file
sudo visudo
Explain the 'cat' command
this allows you to display an entire file at once
Explain 'userdel' command and what option must you use to delete user's home directory
used to delete users from the system and '-r' option is used. ex: Enter the command to remove the account for Jake Moore: sudo userdel -r jmoore
What is a hash algorithm?
used to scrambe up the password by giving it a long string of random characters only the system can understand
What do the /etc and /var directories contain
vital information such as configuration files and log files respectively.
Explain 'passwd' command and what file would you access to verify changes?
we use this command to set user passwords. /etc/shadow file to verify changes and the password.
What are the values for file permissions?
▪ Read = 4 ▪ Write = 2 ▪ Execute = 1 ▪ No permission = 0
Explain this piece of information found in the /etc/psswd file about user accounts. user:x:1000:1000:User:/home/user:/bin/bash
▪ The first part is the username. In this case "user". ▪ The next is marked with an "x". In older versions of Linux, this is where the password would have been stored. The "x" is just a place holder now. ▪ The first number is the User Identification Number (UID). This is how the system identifies the user. Each user gets a unique number. When a new user is created, their UID will be the next number in sequence. System Administration Assignment 4 - Linux Users, Groups and Permissions Copyright © 2019, University of Cincinnati, Ohio. All rights reserved. ▪ The second number is the Group ID (GID) of the user's primary group. When a user is created, a group is created with their username and is assigned a GID. We will see these in a moment. ▪ The next section is for a comment about the user account. In most cases, this will include the user's full name. ▪ Next is the path to the user's home directory. This allows the system to know which directory to place them in when they log on. ▪ Finally, the last section tells the system which command shell to use. In most cases this will be /bin/bash for the BASH shell. Also, /sbin/nologin is another common option. This causes the user to not be able to log into their system locally. This is often used for accounts created for applications.