RedHat Flashcards

1
Q

w command

A

displays a list of users currently logged into the computer. This is especially useful to show which users are logged in using ssh from which remote locations, and what they are doing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

ssh command

A

encrypts the connection to secure the communication against eavesdropping or hijacking of the passwords and content; i option is used to specify the user’s private key file; the private key file must be readable only by the user that owns the file (chmod 600 could be used to ensure this)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

exit command

A

terminate the current shell session. Alternatively, finish a session by pressing Ctrl+D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

date command

A

displays the current date and time; can be used to calculate a date in the future: date -d “+45 days” -u (The -u option reports the time in UTC.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

passwd command

A

changes a user’s own password; The superuser can use the passwd command to change other users’ passwords; passwd username command sets the initial password or changes the existing password of username.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

file command

A

scans the beginning of a file’s contents and displays what type it is. The files to be classified are passed as arguments to the command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

cat command

A

create single or multiple files, view the contents of files, concatenate the contents from multiple files, and redirect contents of the file to a terminal or files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

less command

A

displays one page of a file at a time and lets you scroll at your leisure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

head and tail commands

A

display the beginning and end of a file, respectively. By default these commands display 10 lines of the file, but they both have a -n option that allows a different number of lines to be specified. The file to display is passed as an argument to these commands.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

wc command

A

counts lines, words, and characters in a file. It takes a -l, -w, or -c option to display only the number of lines, words, or characters, respectively.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

useradd command

A

used by the superuser, root, to create additional users on the system; Tab completion following a partial option can be used to complete the option without a lot of typing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

history command

A

displays a list of previously executed commands prefixed with a command number; exclamation point character (!) is a metacharacter that is used to expand previous commands without having to retype them. The !number command expands to the command matching the number specified. The !string command expands to the most recent command that begins with the string specified.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

/ directory

A

root directory at the top of the file-system hierarchy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

• static

A

content remains unchanged until explicitly edited or reconfigured

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

• dynamic or variable

A

content may be modified or appended by active processes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

• persistent

A

content remains after a reboot, like configuration settings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

• runtime

A

process- or system-specific content that is deleted by a reboot

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

/usr

A

Installed software, shared libraries, include files, and read-only program data. Important subdirectories include:
• /usr/bin: User commands.
• /usr/sbin: System administration commands.
• /usr/local: Locally customized software.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

/etc

A

Configuration files specific to this system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

/var

A

Variable data specific to this system that should persist between boots. Files that dynamically change, such as databases, cache directories, log files, printer-spooled documents, and website content may be found under /var.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

/run

A

Runtime data for processes started since the last boot. This includes process ID files and lock files, among other things. The contents of this directory are recreated on reboot. This directory consolidates /var/run and /var/lock from earlier versions of Red Hat Enterprise Linux.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

/home

A

Home directories are where regular users store their personal data and configuration files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

/root

A

Home directory for the administrative superuser, root.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

/tmp

A

A world-writable space for temporary files. Files which have not been accessed, changed, or modified for 10 days are deleted from this directory automatically. Another temporary directory exists, /var/tmp, in which files that have not been accessed, changed, or modified in more than 30 days are deleted automatically.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

/boot

A

Files needed in order to start the boot process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

/dev

A

Contains special device files that are used by the system to access hardware.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

absolute path

A

fully qualified name, specifying the files exact location in the file system hierarchy. It begins at the root (/) directory and specifies each subdirectory that must be traversed to reach the specific file. A path name with a forward slash (/) as the first character is an absolute path name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

working directory or current working directory

A

current location

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

relative path

A

identifies a unique file, specifying only the path necessary to reach the file from the working directory; path name with anything other than a forward slash as the first character is a relative path name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

pwd command

A

displays the full path name of the current working directory for that shell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

ls command

A

lists directory contents for the specified directory or, if no directory is given, for the current working directory; To view the owner of a file use the ls -l command. To view the owner of a directory use the ls -ld command. In the following output, the third column shows the username.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

cd command

A

change your shell’s current working directory. If you do not specify any arguments to the command, it will change to your home directory; command cd - changes to the previous directory; cd .. command uses the .. hidden directory to move up one level to the parent directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

touch command

A

normally updates a file’s timestamp to the current date and time without otherwise modifying it. This is useful for creating empty files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

(.)

A

current directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

(..)

A

parent directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

hidden files

A

File names beginning with a dot (.) indicate hidden files; you cannot see them in the normal view using ls and other commands. This is not a security feature. Hidden files keep necessary user configuration files from cluttering home directories.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

mkdir command

A

creates one or more directories or subdirectories; -p (parent) option creates missing parent directories for the requested destination; Use the mkdir command and a space-delimited list of the directory names to create multiple directories.; Use the mkdir -p command and space-delimited relative paths for each of the subdirectory names to create multiple parent directories with subdirectories.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

cp command

A

copies a file, creating a new file either in the current directory or in a specified directory. It can also copy multiple files to a directory; Warning - If the destination file already exists, the cp command overwrites the file.; When copying multiple files with one command, the last argument must be a directory.; By default, the cp does not copy directories; it ignores them.; Use the copy command with the -r (recursive) option, to copy the directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

mv command

A

moves files from one location to another; Use the mv command to rename a file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

rm command

A

removes files. By default, rm will not remove directories that contain files, unless you add the -r or –recursive option; use the rm -ri command to interactively prompt for confirmation before deleting. This is essentially the opposite of using the -f option, which forces the removal without prompting the user for confirmation; Warning - If you specify both the -i and -f options, the -f option takes priority and you will not be prompted for confirmation before rm deletes files.; use the rmdir command, rm -d (which is equivalent to rmdir), or rm -r to remove an empty directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

Hard Links

A

You can find out if a file has multiple hard links with the ls -l command. One of the things it reports is each file’s link count, the number of hard links the file has.; If you want to find out whether two files are hard links of each other, one way is to use the -i option with the ls command to list the files’ inode number.; Even if the original file gets deleted, the contents of the file are still available as long as at least one hard link exists. Data is only deleted from storage when the last hard link is deleted.; • A hard link points a name to data on a storage device

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

Soft Links

A

soft link (sometimes called a symbolic link); the first character of the long listing is l instead of -. This indicates that the file is a soft link and not a regular file; • A soft link points a name to another name, that points to data on a storage device; by default cd will update your current working directory using the name of the soft link rather than the name of the actual directory. (There is an option, -P, that will update it with the name of the actual directory instead.)

43
Q

ln command

A

to create a new hard link (another name) that points to an existing file. The command needs at least two arguments, a path to the existing file, and the path to the hard link that you want to create.

44
Q

df command

A

list the directories that are on different file systems; Files in two different “Mounted on” directories and their subdirectories are on different file systems.

45
Q

ln -s command

A

creates a soft link, which is also called a “symbolic link.” A soft link is not a regular file, but a special type of file that points to an existing file or directory.
• They can link two files on different file systems.
• They can point to a directory or special file, not just a regular file.
The command needs at least two arguments, a path to the existing file, and the path to the soft link that you want to create.

46
Q

tilde character (~)

A

matches the current user’s home directory

47
Q

Brace Expansion | echo command

A

echo command can also be used to display the values of brace and variable expansion characters, and others; double-dot syntax (..) expands to a sequence; Braces contain a comma-separated list of strings, or a sequence expression

48
Q

single quotes (‘) or double quotes (“)

A

used to enclose strings. They have slightly different effects. Single quotes stop all shell expansion. Double quotes stop most shell expansion.
Use double quotation marks to suppress globbing and shell expansion, but still allow command and variable substitution.

49
Q

man -k keyword

A

displays a list of keyword-matching man page topics with section numbers; The man command -K (uppercase) option performs a full-text page search, not just titles and descriptions like the -k option. A full-text search uses greater system resources and take more time.

50
Q

whereis command

A

Locate the binary, source, and manual pages located in the /usr/share/man directory

51
Q

pinfo command

A

launch the Info document viewer; Info documents typically cover particular software packages as a whole, tend to have more practical examples of how to use the software, and are structured as hypertext documents.

52
Q

> file

A

redirect stdout to overwrite a file

53
Q

> > file

A

redirect stdout to append to a file

54
Q

2> file

A

redirect stderr to overwrite a file

55
Q

2> /dev/null

A

discard stderr error messages by redirecting to /dev/null

56
Q

> file 2>&1&> file

A

redirect stdout and stderr to overwrite the same file

57
Q

> > file 2>&1&» file

A

redirect stdout and stderr to append to the same file

58
Q

> file 2>&1

A

redirects standard output to file and then redirects standard error to the same place as standard output (file)

59
Q

2>&1 > file

A

redirects standard error to the default place for standard output (the terminal window, so no change) and then redirects only standard output to file.

60
Q

&>file or >file 2>&1

A

• Store output and generated errors together.

61
Q

&»file or&raquo_space;file 2>&1

A

append output and generated errors together

62
Q

less command

A

display output on the terminal one screen at a time.

63
Q

tee command

A

tee copies its standard input to its standard output and also redirects its standard output to the files named as arguments to the command

64
Q

pipe character (|)

A

connects the standard output of the first command to the standard input of the next command; Standard error can be redirected through a pipe, but the merging redirection operators (&> and &») cannot be used to do this; 2>&1 is the correct way to redirect both standard output and standard error through a pipe

65
Q

set command

A

list all shell variables that are currently set

66
Q

Retrieving Values with Variable Expansion

A

precede the name of the variable with a dollar sign ($); echo $VARIABLENAME

67
Q

PATH variable: echo $PATH

A

contains a list of colon-separated directories that contain programs; When you run a command such as ls, the shell looks for the executable file ls in each of those directories in order, and runs the first matching file it finds. (On a typical system, this is /usr/bin/ls.); add additional directories to the end of your PATH.
add /home/user/sbin to the end of your PATH for the current session like this:
[user@host ~]$ export PATH=${PATH}:/home/user/sbin

68
Q

env command

A

list all the environment variables for a particular shell

69
Q

Setting the Default Text Editor

A

export EDITOR=nano

70
Q

Setting Variables Automatically

A

Assuming the default /etc/profile, /etc/bashrc, and ~/.bash_profile files, if you want to make a change to your user account that affects all your interactive shell prompts at startup, edit your ~/.bashrc file.

71
Q

unset command

A

unset and unexport a variable entirely

72
Q

export -n command

A

unexport a variable without unsetting it

73
Q

id command

A

show information about the currently logged-in user; To view basic information about another user, pass the username to the id command as an argument.

74
Q

ps command

A

view process information; The default is to show only processes in the current shell. Add the a option to view all processes with a terminal. To view the user associated with a process, include the u option.

75
Q

su command

A

allows users to switch to a different user account; The command su starts a non-login shell, while the command su - (with the dash option) starts a login shell. The main distinction between the two commands is that su - sets up the shell environment as if it were a new login as that user, while su just starts a shell as that user, but uses the original user’s environment settings.; administrators should run su - to get a shell with the target user’s normal environment settings.

76
Q

sudo

A

all commands executed are logged by default to /var/log/secure; all members of the wheel group can use sudo to run commands as any user, including root; run sudo su - from that account to get an interactive root user shell; Another way to access the root account with sudo is to use the sudo -i command. This will switch to the root account and run that user’s default shell (usually bash) and associated shell login scripts. If you just want to run the shell, you can use the sudo -s command.; The main configuration file for sudo is /etc/sudoers. To avoid problems if multiple administrators try to edit it at the same time, it should only be edited with the special visudo command.

77
Q

enable full sudo access

A

To enable full sudo access for the user user01, you could create /etc/sudoers.d/user01 with the following content:
user01 ALL=(ALL) ALL
To enable full sudo access for the group group01, you could create /etc/sudoers.d/group01 with the following content:
%group01 ALL=(ALL) ALL
It is also possible to set up sudo to allow a user to run commands as another user without entering their password:
ansible ALL=(ALL) NOPASSWD:ALL

78
Q

default configuration of the sudo -i

A

You can make sudo -i behave more like su - by editing /etc/sudoers with visudo. Find the line
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
and replace it with the following two lines:
Defaults secure_path = /usr/local/bin:/usr/bin
Defaults>root secure_path = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

79
Q

useradd username command

A

creates a new user named username. It sets up the user’s home directory and account information, and creates a private group for the user named username. At this point the account does not have a valid password set, and the user cannot log in until a password is set.; • Some defaults, such as the range of valid UID numbers and default password aging rules, are read from the /etc/login.defs file. Values in this file are only used when creating new users. A change to this file does not affect existing users.; the useradd command assigns new users the first free UID greater than or equal to 1000, unless you explicitly specify one using the -u option

80
Q

usermod options

A
  • c, –comment COMMENT Add the user’s real name to the comment field.
  • g, –gid GROUP Specify the primary group for the user account.
  • G, –groups GROUPS Specify a comma-separated list of supplementary groups for the user account.
  • a, –append Used with the -G option to add the supplementary groups to the user’s current set of group memberships instead of replacing the set of supplementary groups with a new set.
  • d, –home HOME_DIR Specify a particular home directory for the user account.
  • m, –move-home Move the user’s home directory to a new location. Must be used with the -d option.
  • s, –shell SHELL Specify a particular login shell for the user account.
  • L, –lock Lock the user account.
  • U, –unlock Unlock the user account.
81
Q

userdel username command

A

removes the details of username from /etc/passwd, but leaves the user’s home directory intact

82
Q

userdel -r username

A

removes the details of username from /etc/passwd and also deletes the user’s home directory

83
Q

find / -nouser -o -nogroup command

A

find all unowned files and directories.

84
Q

UID Ranges

A
  • UID 0 is always assigned to the superuser account, root.
  • UID 1-200 is a range of “system users” assigned statically to system processes by Red Hat.
  • UID 201-999 is a range of “system users” used by system processes that do not own files on the file system. They are typically assigned dynamically from the available pool when the software that needs them is installed. Programs run as these “unprivileged” system users in order to limit their access to only the resources they need to function.
  • UID 1000+ is the range available for assignment to regular users.

Default ranges used by useradd and groupadd can be changed in the /etc/login.defs file.

85
Q

groupadd command

A

creates groups; -g option specifies a particular GID for the group to use; -r option creates a system group using a GID from the range of valid system GIDs listed in the /etc/login.defs file; • The SYS_GID_MIN and SYS_GID_MAX configuration items in /etc/login.defs define the range of system GIDs.

86
Q

groupmod command

A

changes the properties of an existing group; -n option specifies a new name for the group.; -g option specifies a new GID

87
Q

groupdel command

A

removes groups; You cannot remove a group if it is the primary group of any existing user.

88
Q

chage command

A

implement a password aging policy; The preceding chage command uses the -m, -M, -W, and -I options to set the minimum age, maximum age, warning period, and inactivity period of the user’s password, respectively.

89
Q

chmod command

A

change permissions
chmod WhoWhatWhich file|directory
• Who is u, g, o, a (for user, group, other, all)
• What is +, -, = (for add, remove, set exactly)
• Which is r, w, x (for read, write, execute)
(using a capital X as the permission flag will add execute permission only if the file is a directory or already has execute set for user, group, or other)
-R option to recursively set permissions on the files in an entire directory tree

90
Q

chown command

A

change file ownership; can be used with the -R option to recursively change the ownership of an entire directory tree; can also be used to change group ownership of a file by preceding the group name with a colon (:); can also be used to change both owner and group at the same time by using the owner:group syntax; You may encounter examples of chown commands using an alternative syntax that separates owner and group with a period instead of a colon (You should not use this syntax. Always use a colon. A period is a valid character in a user name, but a colon is not. )

91
Q

umask command

A

display the current value of the shell’s umask; The system’s default umask values for Bash shell users are defined in the /etc/profile and /etc/bashrc files. Users can override the system defaults in the .bash_profile and .bashrc files in their home directories.; The default umask for users is set by the shell startup scripts. By default, if your account’s UID is 200 or more and your username and primary group name are the same, you will be assigned a umask of 002. Otherwise, your umask will be 022.; As root, you can change this by adding a shell startup script named /etc/profile.d/local-umask.sh

92
Q

ps command

A

listing current processes; displays once

93
Q

top command

A

show the state of each process; display that dynamically updates

94
Q

jobs command

A

display the list of jobs that Bash is tracking for a particular

95
Q

fg command / &

A

A background job can be brought to the foreground with its job ID (%job number).; Any command or pipeline can be started in the background by appending an ampersand (&) to the end of the command line.; To send a foreground process to the background, first press the keyboard generated suspend request (Ctrl+z) in the terminal.

96
Q

ps j command

A

displays information relating to jobs. The PID is the unique process ID of the process. THe PPID is the PID of the parent process of this process, the process that started (forked) it. The PGID is the PID of the process group leader, normally the first process in the job’s pipeline. The SID is the PID of the session leader, which (for a job) is normally the interactive shell that is running on its controlling terminal.

97
Q

bg command

A

To start the suspended process running in the background, use the same job ID.

98
Q

kill command

A

sends a signal to a process by PID number. Despite its name, the kill command can be used to send any signal, not just those for terminating programs. You can use the kill -l command to list the names and numbers of all available signals.

99
Q

pkill command

A

send a signal to one or more processes which match selection criteria. Selection criteria can be a command name, a process owned by a specific user, or all system-wide processes

100
Q

w command

A

list user logins and current running processes; All user login sessions are associated with a terminal device (TTY). If the device name is of the form pts/N, it is a pseudo-terminal associated with a graphical terminal window or remote login session. If it is of the form ttyN, the user is on a system console, alternate console, or other directly connected terminal device.

101
Q

pgrep command

A

lists processes (which operates much like pkill, including using the same options)

102
Q

pstree command

A

view a process tree for the system or a single user

103
Q

uptime command

A

display the current load average. It prints the current time, how long the machine has been up, how many user sessions are running, and the current load average.