Linux Commands and General Knowledge
299 flashcards · Mathematics · by Case Deckard
rsync argument to copy files which are symbolic links as such
rsync -l
rsync argument to retain group permissions for files
rsync -g
cat argument to omit empty lines
cat -l
cat argument to view line numbers
cat -n
cat argument to show $ character at the end of lines
cat -E
cat argument to show all non-printing characters
cat -vET
cat argument to show tabs as ^I
cat -T
Command to querie the DNS server to determine the IP addresses assigned to the hostname
host [www.google.com]
argument for rsync to run in archive mode ( preserves time stamps, performs a recursive copy, keeps all file and directory permissions, preserves owner and group information, and copies any symbolic links. )
rsync -a
command to see one liner descriptions of Linux commands
whatis [command name]
Command to view detailed records for a hostname or network address
dig [ip addr or hostname]
cp option to ask before overwrtiting preexisting files with the same name
cp -f (force)
cp option to give detailed output
cp -v (verbose)
cp option to only overwrite preexisting destination files with the same name if the source files are newer.
cp -u (update)
cp option to perform recursive copy and keep all original attributes such as permissions, ownership and timestamps
cp -a (all)
cp argument to copy arguments recursively
cp -r (or R)
cp option to run in interactive mode and ask before overwriting files
cp -i
execute a gawk program in sandbox mode
gawk -s
Use a gawk program file as source code
gawk -f
Change the default field separator in gawk
gawk -F
How do you use iwlist to find all the in range wireless networks with a device named wlp2s0?
sudo iwlist wlp2s0 scan
Program to show/manipulate the IP routing table
route
How would you use ifconfig to bring down the driver for a device named wlp2s0?
ifconfig down wlp2s0
ls flag to list contents in reverse order
ls -r (reverse)
ls option to classify each type of file using an indicator code
ls -F
ls option to display a dir's metadata instead of it's contents
ls -d
ls option to list directories recursively
ls -R
mkdir option to create parent directories if needed
mkdir -p
mkdir option to set SELinux security context for each created dir to the defualt type
mkdir -Z
mv argument to ensure that no files are overwritten
mv -n (no clobber)
mv argument to only overwrite pre existing files if the files being moved into the new directory are newer
mv -u (update)
nmap command to scan your host computer and see which ports are open from 1-1000
nmap localhost -p 1-1000
redirection operator to send STDERR to a file
2> or 2>> to append
How to redirect STDERR and STDOUT to a file?
&> or &>> to append
rm option for deleting empty directories
rm -d
rm option to run in interactive mode when deleting more than three files
rm -I (capital i)
rsyc option to specify the connection type
rsync -e
rsync argument to retain a file's permissions
rsync -p
rsync option to retain a files modification time
rsync -t
Check if the file is already sorted. Produces no output if the file is sorted.
sort -c
Consider lowercase characters as uppercase characters when sorting.
sort -f (fold)
Sort according to month. Months must be abbreivated as standard such as Jan, Feb etc
sort -M (months)
Sort data using the data in column n, what flag to use a different field (space is the default)
sort -k n -t ':'
sort option to send output to a file
sort -o (output)
sort text using numerical order
sort -n
sort the contents of a file in reverse order
sort -r
systemctl command to allow the service to start automatically at system boot time
systemctl enable [service name]
tar argument to create a new archive
tar -c
tar option to list the contents of an archive.
tar -t
wc option to display in bytes the longest line
wc -L
wc option to display the character count
wc -m
wc option to display the total word count
wc -w
wc option to display the total new line count
wc -l
wc option to display the file's byte count
wc -c
What does ifconfig stand for? What is it's job?
interface config. Configure a network interface
What does the ip commnd do?
show / manipulate routing, network devices, interfaces and tunnels
What is the command used for configuring wireless network interfaces?
iwconfig
what is the symbol to redirect standard input?
<
Where is the directory that containts all the files for various time zones?
/usr/share/zoneinfo
systemctl command to list all the units in failed state
systemctl --failed
command to view which unit files need to start before the ssh.service unit file starts.
systemctl list-dependencies --before ssh.service
what is the command to test how long a command (program) took to execute
time [command name]
in the time command output what do the 'real', 'user' and 'sys' fields refer to?
real: how much actual time the program took to run user: the amount of user CPU time the program used sys: the amount of system CPU time the program used
ASCII character set uses how many bits to store characters?
7 bits (byte is 8 bits)
UFT-8 and UTF-16 use how many bits and bytes
8, 16 (easy) and 1 and 2 (8 bits per byte)
How many bytes does Unicode use?
3 (or 24 bits)
What two environmental variables control all localization settings?
LANG and LC_ALL
Which command can you use to change the value of a localization env variable?
localectl
what is the difference between locale and localectl?
locale just lists localization settings, with localectl you can change these and view much more data on localization.
where is the UID (user id) stored?
All the which environment variable which environment variable user id's are stored in the third field of the /etc/passwd file.
where is the file that controls the process of the useradd command?
/etc/default/useradd
what is the /etc/skel directory for?
The skel directory holds files that are to be copied into a users home directory when the account is created.
What is the first field in the /etc/shadow directory?
the username
What is the second field in the /etc/shadow directory?
The password field.
In the password field of the /etc/shadow file what does a '*' or '!' indicate?
That the account cannot log on.
What does an '!' mean when it is in front of the password field of the /etc/shadow file?
that the account has been locked.
What is the 4th field of the /etc/shadow file?
the number of days after a password is changed until the password may be changed again.
What is the 5th field of the /etc/shadow file?
the number of days until a password change is required.
What is the 6th field of the /etc/shadow file?
the number of days until the user will be warned to change their password.
what is the 7th field of the /etc/shadow file?
the number of days after a password has expired and has not been changed until the account will be deactivated.
What is the 8th field of the /etc/shadow file?
date of the accounts expiration in Unix Epoch Time (in days).
What is the 9th field of the /etc/shadow file?
the 'special flag'. This field is reserved for future use and is currently unused.
What is the flag with the useradd command to see default creation settings?
useradd -D
what is the useradd argument give a comment which is usually the user's full name.
usermod -c [name]
what is the useradd argument to set the expiration date?
usermod -e [yyyy-mm-dd]
What is the useradd argument to change the number of days after a password has expired and has not been changed until the user's account will be deactivated. What is the argument to never let the account be deactivated.
useradd -f [-1]
what is the useradd flag to set the user's group id (GUID)?
useradd -g
what is the useradd flag to manually set their UID?
useradd -u
what is the useradd flag to create a system account instead of a user account?
useradd -r
how can you see all the groups on the system?
getent group
use getent to see who is a member of the group called adm
getent group adm
use getent to see what groups a user named 'sally' is a member of.
getent group sally
what is the command to force a user to change their password?
passwd -e [user name]
what is the passwd option to set the number of days after a password has expired and not changed until the account will be deactivated?
sudo passwd -i (i for inactive)
what is the passwd option to lock a user's account nd stop them from logging on?
sudo passwd -l [username] (lowercase L for 'lock')
what is the passwd option to set the number of days a warning is issued to a user prior to their password expiring.
passwd -w [username]
what is the passwd option to unlock a user's account and allow them to log back in?
passwd -u [username] (u for unlock)
Usermod argument to modify the account's username to the specified new name. Does not modify the home directory.
usermod -l (llowercase 'L' for logiin)
usermod argument to lock the account, places an exclamation point in front of the password of the /etc/shadow file.
usermod -L (L for lock)