Chapter 1-3 Commands
Which permission operator grants permissions
+
Which permission operator denies permissions
-
This file provides system wide environment variables. This is more effective for administrators to configure if there are settings to apply for all users. The system reads on initial login this file first, then the .profile file, and the .profile file is read every time a new shell is run, while the "answer to this question" file is only run at login.
/etc/profile
This directory servers as a storage location for scripts administrators may use to set addition system-wide variables.
/etc/profile.d/
A storage location for hashed passwords as well as additional information only the root has access to
/etc/shadow
The contents of this directory are automatically copied into the home directories of new users. Administrators can pre-load this directory with configuration files or other content. When the useradd command is run, this directory is copied into the new user's home, giving the new user access to the configurations they might need.
/etc/skel/
Directory that contains documents for libraries, system utilities, and other software packages installed on the system.
/usr/share/doc/
Create user accounts and configure basic settings.
useradd
View the default configuration for new users
useradd -D
Sets the comment field for an account, which is usually the user's full name
useradd -c "Example Name" example
Searches the name section of all man pages for the keyword that the user provides. Useful for finding a command when you don't know its name but rather its function
apropos
Displays history of user login and logout actions, along with the time of which they have done so
last
View contents of a file when those contents won't fit entirely on the screen
less
Lists the contents of a directory.
ls
Lists contents of directory and shows hidden files
ls -a
Lists contents of directory in long format
ls -l
Shows the current directory you're in
pwd
Which permission attribute represents the ability to access and view contents of a file, and ability to list contents of a directory
r
reboots the system without using the shutdown command
reboot
shuts down the system in 90 seconds
shutdown -h -t 90
Shuts down the system with no delay
shutdown -h now
reboots the system with no time delay using the shutdown command
shutdown -r now
Pauses system activities for 60 seconds
sleep 60
Which command enables a user to log in to a system with their own credentials, and then to become the root user to perform administrative tasks?
su
Switch the user to root user
su - root
A fellow administrator calls you and needs you to check the /etc/shadow file for a new user's entry, confirming that it indeed exists. How would you look at the contents of the /etc/shadow file without the possibility of changing the file?
su -root, cat /etc/shadow
Any user who knows the root password can get root permissions using this command without substituting for the root user
sudo
Command that enables a user to edit a file with their own credentials even if the file is only accessible to the root user
sudoedit
To use the sudoedit command under a given user, you must make an edit to which file?
sudoers
Updates the timestamp on a file that exists or creates a new file
touch
You need to quickly create an empty file (log.txt) so that an application can copy data into it. Which command can you use to create the file?
touch log.txt
The first character in the ls -l command represents the
type of object
Which permission context represents the owner or user of a file or directory
u
Sets an accounts expiration date
useradd -e exampledate
Sets a user's default shell
useradd -s /bin/ksh
Three commands that are used to edit the /etc/passwd file
useradd usermod userdel
Starts the defualt editor for linux
vim
A command that allows the system to verify the syntax of the /etc/sudoers file before committing changes, which allows you to correct a mistake before they become a part of the configuration
visudo
What command is used to edit the privileges' of the wheel group
visudo
Checks the existing sudoers file for errors
visudo -c
Edit or check a sudoers file in a different location than the default location
visudo -f example
Check the sudoers file in strict mode, any aliases that are used before being defined will result in errors
visudo -s
Output the sudoers file to the specified file in javascript object notation or JSON format
visudo -x example
Displays details of users who are currently logged in to a system and their transactions
w
Which permission attribute represents the ability to save changes to a file or create, rename, and delete files in a directory (also requires the execute attribute to also be set)
w
Display a brief description of a given command including commands that appear in multiple sections. The opposite of apropos, for when you know the name but not what it does
whatis
A group that can exercise administrative privileges of the root user with less potential damage to the system. These users can use the sudo command without logging into the root account
wheel
Determine the details of who is logged into the system.
who
See how long users have been idle logged into a machine
who -u
Displays the username you are currently logged into the system as
whoami
Which permission attribute represents the ability to run a script, program, or other software file and access a directory, execute a file from that directory, or perform a task on that directory like a search
x
Which permission context represents the file or directory's group and all users belonging to that group
g
A file storage location for groups, all groups will be found on this file
/etc/group
A file that stores user account information.
/etc/passwd
the fifth block or number 11 in the ls -l command represents the ( period for SELinux security context and plus for any other combination of alternative access methods)
access method
Starts a GUI text editor that is easy to use that also requires a desktop enviroment
gedit
Displays a quick summary of usage of a command and a list of arguments that can be used.
--help
Shell configuration file for the initial login environment. This file is only read with the first login.
.bash_profile
A file that enables customization of the user's environment, for example the use of aliases for abbreviated commands. This enables them to not impact other users while enhancing their experience. (username, system hostname, current directory, defualt directory, and file permissions are also stored here)
.bashrc
This file allows for user customization and is read by the system every time a new shell is opened.
.profile
This file provides you with system wide bash settings, which differs from the /etc/profile file which is for variables.
/etc/bashrc
Which permission context represents all three permission attribute contexts?
a
View contents of a file without the option to edit the file
cat
Changes your working directory
cd
The command that enables you to modify the permissions of a file or directory. Only the owner of the file or directory or sysadmin can change the permissions of the object
chmod
Modify permissions of files and directories recursively
chmod -R
Report changes that are mode in permissions
chmod -c
Hide most error messages when modifying permissions of a file or directory
chmod -f
Display a diagnostic entry for every file processed while modifying file permissions
chmod -v
Empty the screen of previous commands to eliminate distracting information
clear
Bash syntax
command -options arguments
Copies a file or directory to another location
cp
Repeats input back to the user on the screen. Commonly used to send information to the user in a script
echo
the third block or numbers 5-7 of the ls -l command represent the
group permissions
The command that creates a group
groupadd
Exists with success if the group already exists
groupadd -f groupname
Assigns an ID to a group
groupadd -g 1234 groupname
Allows a group to be created with a non-unique group ID
groupadd -o -g groupname
Commands to properly edit the /etc/group file
groupadd groupmod groupdel
Delete a group from the /etc/group file. It doesn't delete the user accounts in the group
groupdel
Command to change a group's own attributes
groupmod
Change the group ID
groupmod -g 123 groupname
Rename a group
groupmod -n newgroupname oldgroupname
Shows most recently entered commands
history
Displays user ID and group ID information. You can specify a user name as an option to display ID information about a specific user.
id
Displays the info page of a command, which are alternatives to the man pages and favored by GNU project.
info
Lists contents of a specific directory
ls /example/
Understand a command using a command without using the internet
man
Displays debugging information for a command
man -D
Searches for a specified string on all man pages
man -K
Find all man pages matching a query
man -a
Displays a short description of a command along with the man page
man -f
Displays help options for a man command
man -h
Lists all manual pages containing the keyword along with their location
man -k
Makes a new directory
mkdir
Simplier user friendly text editor
nano
Which permission context represents all other users who are not users/owners or group members
o
the fourth block or numbers 8-10 in the ls -l command represent the
other permissions
the second block or numbers 2-4 in the ls -l command represent the
owner permissions
A command used by root to set or reset a password for any user. A user can also reset their own password. Use this after the useradd command
passwd