RedHat Flashcards
w command
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
ssh command
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)
exit command
terminate the current shell session. Alternatively, finish a session by pressing Ctrl+D
date command
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.)
passwd command
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.
file command
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.
cat command
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.
less command
displays one page of a file at a time and lets you scroll at your leisure.
head and tail commands
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.
wc command
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.
useradd command
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.
history command
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.
/ directory
root directory at the top of the file-system hierarchy
• static
content remains unchanged until explicitly edited or reconfigured
• dynamic or variable
content may be modified or appended by active processes
• persistent
content remains after a reboot, like configuration settings
• runtime
process- or system-specific content that is deleted by a reboot
/usr
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.
/etc
Configuration files specific to this system.
/var
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.
/run
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.
/home
Home directories are where regular users store their personal data and configuration files.
/root
Home directory for the administrative superuser, root.
/tmp
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.
/boot
Files needed in order to start the boot process.
/dev
Contains special device files that are used by the system to access hardware.
absolute path
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
working directory or current working directory
current location
relative path
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
pwd command
displays the full path name of the current working directory for that shell
ls command
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.
cd command
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
touch command
normally updates a file’s timestamp to the current date and time without otherwise modifying it. This is useful for creating empty files
(.)
current directory
(..)
parent directory
hidden files
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.
mkdir command
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.
cp command
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
mv command
moves files from one location to another; Use the mv command to rename a file.
rm command
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
Hard Links
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