Basic Commands Flashcards
What command parses the /proc/meminfo file for easier analysis of memory usage statistics?
free
Which command displays system usage reports based on data collected from system activity includes type of data and time data was collected?
sar
Which command exposes the local clock, the universal time, and the hardware clock?
timedatectl
which command is used by root to set or reset a password for any user. A user can use this command to reset their own password. what does the option -S do?
passwd -S --status displays 7 fields login name locked password date of last change minimum age maximum age warning period inactivity period ...ages are expressed in days
which command is an interface to the system reference manuals? what do the options -k, -K, -f, -t do?
man
- k searches for keywords and displays matches
- K search for text in all manual pages
- f =whatis displays a short description from the manual pages
- t formats in printable format
which command displays the amount of disk space available on the file system? Options -h, -i,
df -h human readable, -i lists inode information instead of block size
Which command estimates file space usage? Options -h, -c, -a
du -h human readable, -c produce a grand total, -a write counts for all files not just directories
Which command reports central processing unit statistics and input/output statistics for devices and partitions
iostat
what is the file extension for kernel module files…often found in /usr/lib/modules/
.ko
What is the configuration directory/file for modprobe?
/etc/modprobe.d = directory /etc/modprobe.conf = file
Which command is used to add and remove modules from the Linux Kernel? Options -a, -r
modprobe -a = to add modules -r to remove modules
Which command configures kernel parameters at runtime? Options -a, -w, -p, -e, -r
sysctl
- a = display all values currently available -w = when all arguments prescribe a key to be set
- p = –load - load in sysctl settings from a file specified
- e ignore errors
- r only apply settings that match a pattern.
Which command shows the status on modules in the linux kernel and their details?
lsmod
Which command displays information about a particular Linux Kernel module?
modinfo
Which command is a simple program to insert a module into the Linux Kernel?
insmod
Which command is a simple program to remove a module from the Linux Kernel?
rmmod
Which command generates module.dep and maps files? Creates a list of module dependencies by reading each module under /lib/modules/version.
depmod
Which two commands show a listing of last logged in users? Which one of these shows by default a log of the /var/log/btmp file, which contains all the bad login attempts?
last, lastb lastb shows the bad login attempts
Which log file in the /var/log/ directory will give you a complete picture of users logins at which terminals, logouts, system events and current status of the system, system boot time, etc.?
/var/log/utmp
Which log file in the directory /var/log/… give historical data of utmp?
/var/log/wtmp
Which log file in /var/log/… records only failed login attempts?
/var/log/btmp
What does sda1 mean?
sd = SCSI/SATA, a = first whole drive, 1 = first partition on drive
What are the common file attributes a, A, e, i
a = file can only be opened in append mode A = file can be opened without changing its atime (last opened time) e = file is using extents for mapping blocks on disk i = immutable cannot be deleted or renamed
which command repeats input back to user?
echo
Which command lists contents of directory?
ls
Which command displays the current working directory?
pwd
which command changes the current working directory?
cd
which command updates timestamp of file or creates file?
touch
which command copies a file or directory?
cp
which command creates a new directory?
mkdir or newdir
which command shows contents of a file on screen?
cat
which command breaks output into pages?
less
Name three popular text editors?
vim, nano, gedit
What are the differences between shutdown -h now, shutdown -h -t 90, and shutdown -r now?
- h now = shutdown now
- h -t 90 = shutdown in 90 seconds
- r now = reboots with no delay
Which command switches user?
su
Which command outputs a list of recently entered commands?
history
What is a feature in which a command-line shell fills in the name of a command you’ve partially typed?
tab completion
Which command clears the screen?
clear or ctrl + l
Which command searches the NAME section of man pages based on keyword? Helps to find the correct command to use for a certain task.
apropos
Which command displays a brief description of a given command? Helps to figure out what the command does.
whatis
Which command displays the info page of a command? Similar to man pages with some improvements, but is not as widely adopted as man pages.
info
Which command displays a quick summary of command usage and arguments?
–help
What is the directory of documentation for software packages? includes author, licensing, installation, README, etc.
/usr/share/doc/
What are some examples of interactive online sources of help?
Usenet newsgroups, mailing lists, Q&A websites, Forums and social media
What is an object that represents a person’s identity to the operating system and is used to perform certain tasks?
user account
What are the three types of user accounts?
Root user, Standard user, Service user
What is the term for the local administrative account on a Linux system, typically named root?
superuser
What is a best practice that states that users should have as much access as is required to do their job, but no more that that?
Principle of Least Privilege
Which command is used to edit the /etc/sudoers file and cverifies syntax before committing changes and can help correct mistakes before they occur, as mistakes in the sudoers file may render server inoperable.
visudo
Some distros disable root altogether and enable admin privileges by membership to what group? visudo command is used to edit this group’s privileges similar to editing the sudoers file.
The wheel group
Which command creates a user account and configures user settings?
useradd
useradd command will do what?
create account in /etc/passwd file, references /etc/login.defs, creates user’s home directory in /home/account/, and populates home directory from files in /etc/skel
What are the functions of the useradd options -c, -e, -s, -D?
-c = sets comment field, -e = sets account expiration date, -s = sets user’s default shell, -D = view default config for new users
/etc/passwd contains what 7 fields separated by colons?
User name: Password: UserID: GoupID: Comment: Home directory: Login shell
What filed contains hashed version of passwords, and who can access it?
/etc/shadow root
Which command controls password expiration, warnings, inactive days, etc.?
chage
what are functions of the chage command options -E, -l, -M, -m, -W?
-E sets account expiration, -l lists password aging info, -M sets max days password is valid, -m sets minimum days until password can be changed, -W sets number of days before expiration user will be warned
What is the significance of #chage -M 90 user1
sets the maximum days user1’s password is valid to 90 days, performed by root
Which command modifies settings for regular users?
usermod
What are the functions of the usermod options -c, -e, -aG, -l
-c sets comment field, -e sets account expiration date, -aG adds user to group and keeps them in existing groups, -l chages user’s login name
What are two basic ways of locking a user account?
passwd -l , usermod -L
What are two basic ways to unlock a user account?
passwd -u , usermod -U
Which command deletes a user account? However, it does not delete home directory unless you use what option?
userdel -r
What is an access control object that contains multiple users with similar security requirements?
Group Account
What file is the storage location for groups, is commonly referenced for group info, contains four fields separated by colons, and should not be edited manually but rather by group commands?
/etc/group
What are the four fields in the /etc/group file?
Group name: password requirement: group ID: group list
Which command creates groups? By default groups have no members or password.
groupadd
What are the functions of groupadd options -g, -f, -o?
-g assign a group ID, -f exit with success if group already exists, -o allow group creation with non-unique ID
Which command changes a group’s attributes and edits the /etc/group file?
groupmod
What are the functions of the groupmod command options -g, -n?
-g change group ID, -n rename group
Which command deletes groups from /etc/group file, doesn’t delete users?
groupdel
Which command displays the user name you are currently logged in as?
whoami
Which command determines details of users currently logged in?
who
what are three items that the who command will tell you?
user name, system the user is connected to, date/time connected since
Which command displays details of logged in users and transactions?
w
Which command displays UID/GID? Without options it displays info about logged in user, but you can specify user name to display info about that user.
id
Which file enables customization of user’s environment, is stored in home directory, and is unique to each user? examples include use of aliases, environment variables, and customize command prompt.
.bashrc
Which file provides shell configuration for the initial login, but is only read with first login. The default for this file can be provided through /etc/skel/ directory.
.bash_profile
Which directory’s contents are automatically copied to the home directory of new users? the useradd command copies contents from this directory.
/etc/skel/
This file provides system-wide environmental variables, it is configured if settings need to apply to all users, it is checked first during login process for shell configs, then user customizations are pulled from .profile in their home directory. Admins can use this file to define global settings, but still allow user-specific customization.
/etc/profile
Which directory is the storage location for scripts used to set system-wide variables?
/etc/profile.d/ it is recommended to set variables in scripts here rather than edit /etc/profile
This file provides system-wide Bash settings? It is different than /etc/profile which is used for variables.
/etc/bashrc
What is GPT and what specification is it part of?
GUID Partition Table UEFI
What is MBR and what size is it?
Master Boot Record 512 byte-sector in the first sector on the disk
What is mdadm?
mdadm is a Linux utility used to manage and monitor software RAID devices
What is LVM?
Logical Volume Management. It is a system of managing logical volumes, or filesystems, that is much more advanced and flexible than the traditional method of partitioning a disk into one or more segments and formatting that partition with a filesystem
What is Multipath?
Linux multipath provides a way of organizing the I/O paths logically, by creating a single multipath device on top of the underlying devices
Why is multipathing important?
Linux multipathing provides connection fault tolerance and can provide load balancing across the active connections. When multipathing is configured and running, it automatically isolates and identifies device connection failures, and reroutes I/O to alternate connections.
What is the command localectl ?
Control the system locale and keyboard layout settings
fdisk
is a dialog-driven program for creation and manipulation of partition tables. It understands GPT, MBR, Sun, SGI and BSD partition tables.
what are the three permission attributes for directories and files?
r = read, w = write, x = execute
What are the three Permission Contexts?
u = Owner, g = Group, o = other
Which command enables you to modify permissions on files/directories? Can only be done by owner or object or sysadmin.
chmod
chmod -c
enables modification of permissions on files/directories, -c report changes made to permissions
chmod -f
enables modification of permissions on files/directories, -f hide most error messages
chmod -v
enables modification of permissions on files/directories, -v = display diagnostic entry for every object processed
chmod -R
enables modification of permissions on files/directories, -R modify permissions recursively
Which mode of chmod sets permissions using components and operators such as +, -, =?
Symbolic Mode + grants permissions, - denies permissions, = assigns permissions exactly as provided
What does chmod go+rw file1
changes permissions for group and others adding read and write permission for file1
In what mode does chmod use octal numbers and shows compete permission as three digit number?
Absolute Mode
In Absolute Mode, what do the chmod octal numbers 4, 2, 1 represent?
4 = read, 2 = write, 1 = execute
In the Absolute Mode of chmod, what does 764 represent?
owner permissions = 7 (4 read + 2 write + 1 execute), group permissions read +write, other permissions read only
What is the result of chmod 640 file1
permissions for file1 are set to owner 6=rw, group = r, others = none (-)
What are the default permissions for riles created by ROOT user? and for directories?
644 for files, 755 for directories
What are the default permissions for files created by REGULAR users? and for directories?
664 for files, 775 for directories
What command alters default permissions on newly created files/directories, can be useful for automating custom permissions for new objects, can be set for session or per-user (in .bashrc), specifies permissions to remove.
umask
system wide umask is set in what two files? Where is the default umask for for a specific user?
/etc/basrc /etc/profile for a user = ~/.bashrc
the property by which a user can apply and modify the permissions of a file or directory
ownership
Who can modify permissions for a file or directory?
owner & root
Which command changes the owner, group or both for a file or directory?
chown
If you want bob22 to manage a file or directory, but sally1 created the object, which command would allow you allow bob22 to manage permissions for the object?
chown ex: chown bob22 file1
You want to change the owner of file1 to jimmy5 and the group to engineers. what command and what would your syntax look like.
chown jimmy5:engineers file1
Which command allows you to schedule a command to execute by setting a command-line parameter?
at
the cron daemon is control by what command?
crontab
crontab files for system are located in what directory?
/etc/cron.d/
crontab files for users are located in what directory?
/var/spool/cron/