1/71
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Create three directories (reports, archive, scratch) in one command
mkdir reports archive scratch
Create five files log1 through log5 in one command using brace expansion
touch log{1..5}
Move log1 and log2 into the archive directory in one command
mv log1 log2 archive/
Copy log3 into scratch and rename the copy to backup3
cp log3 scratch/backup3
Create a hard link named reportlink pointing to reports/log4
ln reports/log4 reportlink
Create a symbolic link named scratchlink pointing to the scratch directory
ln -s scratch scratchlink
Save the first 3 lines of a file into a new file using redirection
head -3 file > newfile
Append the last 2 lines of a file to an existing file
tail -2 file >> existingfile
Vim command to copy the current line
yy
Vim command to paste a yanked or deleted line below the cursor
p
Vim command to delete the current line
dd
Vim command to save and quit
:wq
Vim command to quit without saving
:q!
Generate an SSH key pair with the default settings
ssh-keygen
Generate an SSH key pair with a custom file name
ssh-keygen -f ~/.ssh/keyname
Push your public key to a remote host for passwordless login
ssh-copy-id -i ~/.ssh/keyname.pub user@host
Run a single remote command over SSH using a specific private key, without opening a shell
ssh -i ~/.ssh/keyname user@host command
Start the SSH agent in your current shell
eval $(ssh-agent)
Load a passphrase-protected private key into the running SSH agent
ssh-add ~/.ssh/keyname
Create a new user named athos
useradd athos
Set or reset the password for user athos to redhat
passwd athos
Change a user's GECOS/comment field to "Operator One"
usermod -c "Operator One" username
Delete a user AND their home directory
userdel -r username
Create a group named musketeers with a specific GID of 22000
groupadd -g 22000 musketeers
Create a group and let the system assign the GID automatically
groupadd groupname
Add an existing user to a supplementary group WITHOUT removing their other groups
usermod -aG groupname username
Two-letter command to confirm a user's group memberships
id username
Which config file shows supplementary group membership for verification
/etc/group
Which config file shows a user's primary group and account info, not supplementary groups
/etc/passwd
Grant an entire group sudo access via sudoers.d
echo "%groupname ALL=(ALL) ALL" >> /etc/sudoers.d/groupname
Grant a single user sudo access via sudoers.d
echo "username ALL=(ALL) ALL" >> /etc/sudoers.d/username
Force a user to change their password at next login
chage -d 0 username
Set the minimum number of days before a password can be changed again
chage -m 10 username
Set the maximum number of days before a password expires
chage -M 30 username
Make umask 007 persistent for a user across logins
echo "umask 007" >> ~/.bashrc then source ~/.bashrc
Change only the group ownership of a file or directory
chown :groupname path (or chgrp groupname path)
Change both owner and group ownership at once
chown user:group path
Add write permission for the group owner using symbolic mode
chmod g+w path
Set permissions to rwxrwx--- using octal notation
chmod 770 path
Set the group's permissions to exactly rwx using symbolic mode
chmod g=rwx path
Set the sticky bit so only a file's owner can delete their own file in a shared directory
chmod o+t path
Set setgid on a directory so new files inherit the directory's group owner
chmod g+s path
Let others view and enter a directory but not modify its contents
chmod o+rx path
Let others cd into your home directory without being able to list its contents
chmod o+x path
Formula to calculate resulting file permissions from a umask value
666 minus the umask value (per digit)
Formula to calculate resulting directory permissions from a umask value
777 minus the umask value (per digit)
Resulting file/directory permissions for umask 022
Files 644, directories 755
Resulting file/directory permissions for umask 027
Files 640, directories 750
Command with no arguments to display your current default umask
umask
Temporarily set umask to 024 for the current shell session only
umask 024
Run a command in the background instead of the foreground
command &
List active and suspended background processes alongside their assigned ID numbers.
jobs
Suspend a running background job referenced by job number 1
kill -SIGSTOP %1
Resume a suspended background job referenced by job number 1
kill -SIGCONT %1
Gracefully ask a process to terminate (the default, catchable signal)
kill -SIGTERM %# (kill %#)
Force-kill a process that ignored SIGTERM
kill -SIGKILL %# (signal number 9)
Kill a process by name instead of by PID or job number
pkill -SIGTERM processname
Find the PID(s) of a running process by name
ps -ef | grep processname (or pgrep -a processname)
Confirm whether a specific PID is still running
ps -p PID
Inside top, which key quits the program
q
List all currently active/loaded service units
systemctl list-units --type=service
List all service unit files with their enabled/disabled state, including inactive ones
systemctl list-unit-files --type=service
Check the detailed current status of a specific service
systemctl status servicename
Check whether a service is set to start automatically at boot
systemctl is-enabled servicename
Check whether a service is currently running right now
systemctl is-active servicename
Start a stopped service immediately
systemctl start servicename
Stop a running service immediately
systemctl stop servicename
Stop and then start a service, changing its PID
systemctl restart servicename
Re-read a service's configuration WITHOUT changing its PID
systemctl reload servicename
Configure a service to start automatically at boot (without changing its current running state)
systemctl enable servicename
Configure a service to NOT start automatically at boot (without stopping it now)
systemctl disable servicename
Reboot the entire machine from the command line
systemctl reboot