D281 - Linux Foundations
WGU - D281 - Linux Foundations
110 flashcards · Computer Science · by Denny Ferrassoli
Red Hat Based Linux Kernels
Red Hat Enterprise Linux (RHEL) Fedora CentOS RPM based packages
Debian Based Linux Kernels
Ubuntu Ubuntu variants: Kubuntu, Zubuntu, Ubuntu Mate (mah-tay) Mint PopOS Any .deb based packages
Non-Debian/RedHat Linux Kernels
Arch Linux Slackware SUSE Android ChromeOS Raspbian Embedded systems
System Info: Command: Display Linux system information
uname -a
System Info: Command: Display kernel release information
uname -r
System Info: Command: Show how long the system has been running + load
uptime
System Info: Command: Display who is online and what they're doing
w
System Info: Command: Display current user
whoami
Hardware Info: Command: Display CPU information
cat /proc/cpuinfo
Hardware Info: Command: Display memory information
cat /proc/meminfo
Hardware Info: Command: Display free and used memory
free or free -h (human readable)
Hardware Info: Command: Display PCI devices
lspci -tv
Hardware Info: Command: Display USB devices
lsusb -tv
Hardware Info: Command: Display information about CPU, memory, storage, and network interfaces
lshw
Perf/Monitoring: Command: Display and manage the top processes
top
Perf/Monitoring: Command: Interactive process viewer (top alternative)
htop
Perf/Monitoring: Command: Display processor related statistics
mpstat 1
Perf/Monitoring: Command: Display virtual memory statistics
vmstat 1
Perf/Monitoring: Command: Display I/O statistics
iostat 1
Perf/Monitoring: Command: Capture and display all packets on interface eth0
tcpdump -i eth0
Perf/Monitoring: Command: Capture and display all packets on interface eth0 PORT 80
tcpdump -i eth0 'port 80'
Perf/Monitoring: Command: List all open files on the system / for user
lsof (all) lsof -u <user> (open files for user)
User Info/Management: Command: Display the user and group ids of your current user
id
User Info/Management: Command: Change current user password
passwd
User Info/Management: Command: Create a new group
groupadd <name>
User Info/Management: Command: Create a new account
useradd -c "comment" -m <username> -c is for a comment -m creates the home directory
User Info/Management: Command: Delete a user account
userdel <username> userdel -r <username> will remove the user home directory and mail spool
User Info/Management: Command: Add user to a group
usermod -aG <group> <user>
File/Directory: Command: List all files in a directory
ls -a ls -al
File/Directory: Command: Show present working directory
pwd
File/Directory: Command: Create symbolic link
ln -s /path/to/file <linkname>
Process Management: Command: Display currently running procs
ps ps -ef (all running procs on system) ps -ef | grep <procname> (search for proc) pa -aux
Process Management: Command: Kill a process
kill <processid>
Process Management: Command: Kill all processes with name
killall <processname>
Process Management: Command: Start a program in the background
<program> &
Process Management: Command: Display stopped or background jobs
bg
Process Management: Command: Bring background job to foreground
fg (most recent) fg <n> (bring job n to foreground)
Process Management: Command: Run process even after user logs out
nohup <processname>
File Permissions: File permission starts with what letter if the file is a directory?
d example directory: drwxrw-r-- example file: -rwxrw-r--
File Permissions: What are the three groups named in file permissions? Example: What does A,B,C stand for in this permission: -AAABBBCCC
User Group Other
File Permissions: What are the three types of permissions you can apply to a file for a user, group, or other?
rwx Read, Write, Execute
File Permissions: Command: Change user ownership of a file
chown <user> /path/to/file
File Permissions: Command: Change group ownership of a file
chgrp <group> /path/to/file
File Permissions: Command: Set permissions of a file to allow the following User: read, write, execute Group: read, execute Other: read
chmod 754 <file> Result = -rwxr-xr-- Also: chmod u+rwx,g+rx-w,o-rwx <file>
Shell: Echo text to a file, replacing the contents
echo testing > file.txt
Shell: Append text to an existing file
echo testing123 >> file.txt
Shell: Chain multiple commands with subsequent commands only running if the previous was successful
command1 && command2 && command3
Shell: Store the current date into a variable
$datenow=`date`
Shell: Store the current date into a variable and concat the text " WOW!" after the date
$datenow="`date` WOW!"
Shell: Store the raw environment variable $PWD in another env variable, and make sure when you echo the new env variable $PWD is not expanded. Example: echo $myvar Should output: $PWD It should not show the present working directory!
myvar='$PWD' Notice single quotes will not expand the variable. Double quotes will expand the variable.
Definition: What is HCL?
Hardware Compatibility List Tested, compatible, hardware devices for a particular distro
What type of multitasking does Linux use?
Preemptive multitasking: a task in which a computer operating system uses some criteria to decide how long to allocate to any one task before giving another task a turn to use the operating system. The act of taking control of the operating system from one task and giving it to another task is called preempting.
Name 3 Linux GUI's
X Window (or X) GNOME KDE Xfce Cinnamon
What year was Unix created?
1969 At AT&T's Bell Labs
What year was the Linux Kernel created?
1991 By Linus Torvalds
What makes up a complete linux-based OS?
Kernel Core Tools (Window system, disk mgr, etc) Supplemental Software (user software) Startup Scripts Installer
Name some package managers used by linux distros
rpm apt dpkg yum
Define IaaS (infrastructure as a service)
Provides low-level hardware, no operating system / apps
Define PaaS (platform as a service)
Provides low-level hardware and operating system
Distro Lifecycle Management: Define STS and LTS
STS = Short-term-support LTS = Long-term-support
Open Source Licenses: The Linux kernel uses which open source license?
GPLv2
Open Source Licenses: What is the main difference between GPLv2 and GPLv3?
GPLv3 contains clauses intended to combat use of hardware restrictions
Shell Commands: How do you share a variable with child shells? Example: thing=1 bash echo $thing 1
export thing=1 bash echo $thing
Shell Commands: How do you create a tar file?
tar -c -f <file>.tar <file(s) or folder(s)>
Shell Commands: How do you extract a tar file?
tar -x -f <file>.tar
Shell commands: Redirect standard err to standard out
Echo "hello" > file.txt 2>&1
Shell commands: Use tail and sort to skip the first line of a file and sort the contents
tail -n +2 | sort
Shell commands: Use cut on a csv file to show the second column
cut -d, -f 2 test.csv
Shell commands: How do you count the number of lines in a file?
wc -l <file> or: grep “test” <file> | wc -l
Filesystem: What folder stores device info?
/dev
Filesystem: What folder stores process info?
/proc
Filesystem: Where are kernel files stored?
/boot
Filesystem: Where are log files stored?
/var/log
Filesystem: Where are configuration files stored?
/etc
Filesystem: Where are system logs stored?
Ubuntu: /var/log/syslog RedHat/Rocky: /var/log/messages
Filesystem: How can we see systemd logs?
journalctl -u cron Log files are going binary! journalctl is the future for looking up logs.
Vocabulary: What does POSIX stand for?
Portable Operating System Interface
Commands: What other command beside man can be used to look up information?
info Example: info info
Filesystem: Where can documentation about programs potentially be found in the filesystem?
/usr/doc /usr/share/doc /usr/share/doc/packages
Commands: What command can search a database of filenames that Linux maintains? (typically updated every 24 hours and can be updated by using the updatedb command)
locate
Commands: How can you recall the last ARGUMENT from the terminal?
!$ Example: touch file{1..100} rm !$
Commands: How can you search your bash history?
Ctrl+R then type to search
Commands: What's the new command that replaces netstat?
ss Example: ss -tuna Similar to: netstat -tuna
Commands: How do you make a named pipe?
mkfifo <pipename>
Commands: How do you listen to the tail of a file?
tail -f <file>
Commands: Which command is ran interactively? ps or top
top
Commands/Logging: How can you view logs for the kernel ring buffer?
dmesg example: dmesg | less dmesg | grep sda (to search for issues with disks)
Packages: What package management tool does Debian use?
apt
Packages: What package management tool does Red-Hat use?
rpm yum
Permissions/Commands: How do you turn on the sticky bit?
chmod -t <folder> chmod 1777 <folder>
Permissions/Commands: What's another way to view the passwd, hosts, or group "databases" other than using a text editor or cat?
getent passwd getent group getent hosts
User Info/Management: Command: How do you view default settings that a user gets when a new user is created?
useradd -D or: /etc/default/useradd
User Info/Management: Command: How do you create a system account?
sudo useradd -r <name>
User Info/Management: Command: How do you check last password change / expiration?
sudo chage -l <user> or less verbose: passwd -S <user> passwd -l <user>
User Info/Management: Command: Command to list the last time all users have logged in
lastlog
User Info/Management: Command: Create a user without a private group
useradd -m -N <user> tail -n1 /etc/passsword should show that <user> does not have a private group (ie: user:x:1006:100::/home/user)
Group Info/Management: Command: Add a user to a group
gpasswd -a <user> <group> or usermod -a -G <group> <user> or edit the /etc/group file
Commands/Files: What command do you use to show details of a file? (including size, access rights, ownership, created on, last update)
stat <file>
Commands/Files: How do I get the read/write/execute permissions of a file in octal format?
stat -c %a <file>
Commands/Files: How do I get the read/write/execute permissions of a file in symbolic format?
stat -c %A <file>