System Administration
System Administration
... Runtime data for processes that started since the last
/run
boot.
mv oldname.txt
The mv command can both move The rmdir command
newname.txt
files to a new location and removes only empty
rename files. rmdir EmptyDir directories.
mv file.txt
path changes, but the content rm -r nonEmptyDir For non-empty directories,
destination_direc
remains unchanged. you must use rm -r.
tory/
Make Links Between Files
You can create multiple file names that point to the same file. These file names are called links.
ln originalfile.txt hardlink.txt
ln -s /path/to/originalfile.txt symlink.txt
ls -il originalfile.txt hardlink.txt # shows same
ls -l symlink.txt # shows the link destination
inode numbers
Match File Names with Shell Expansions ~: Expands to the user's home directory.
Bash Shell Expansions: ~username: Expands to another user's
When a command is typed, Bash performs several Tilde home directory.
expansions to transform it before executing. These Expansion Example:
echo ~user: Outputs /home/user.
include:
Select files by using patterns These patterns
include wildcards Variables store values, which can be accessed
Common wildcards include: using $VARNAME or ${VARNAME}.
Variable
*: Matches any string (including zero Example:
characters).
Expansion USERNAME=operator; echo $USERNAME:
?: Matches any single character. Outputs operator.
Pathname [ABC]: any character inside the brackets.
[!abc] or [^abc]: character not inside the
Expansion Executes a command and replaces it with the
brackets.
(Globbing) [[:alpha:]]: Any alphabetic character output.
[[:alnum:]:Any alphabetic character or digit Done using $(command).
Examples: Command Example:
ls a*: Matches files starting with "a". echo Today is $(date +%A): Outputs Today
Substitution
ls *a*: Matches files containing "a". is Wednesday.
Note:An earlier form of command substitution uses
ls ????: Matches files with exactly four
backticks: `command`. Although the Bash shell still
characters. accepts this format, try to avoid it