Docsity

Linux Shells and Commands Study Guide, Exams of Advanced Education

Toggle sidebar
bg1
CCTC Study Guide Exam with Complete
Solutions
1.1 Describe common shells - Correct Answer-- Bash: default shell for
most linux distributions; sh-compatible; unlimited command history
- Tcsh/Csh: C shell; interactive login shell;
- Ksh: Korn shell; interactive command language
- Zsh: designed to be interactive; includes many indexes not in other
shells (variable, function, key)
- fish: user friendly shell; web based configuration; auto suggestion
1.2 common shell modes - Correct Answer-$ normal user prompt
# root user prompt
-- = posix mode makes bash emulate sh, this will disable the operation
sudo = auto to root
2.1 Where is command history saved to in bash? - Correct Answer--
command history is saved to ~./.bash_history, accessible by pressing
the up arrow key
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Linux Shells and Commands Study Guide and more Exams Advanced Education in PDF only on Docsity!

CCTC Study Guide Exam with Complete

Solutions

1.1 Describe common shells - Correct Answer-- Bash: default shell for most linux distributions; sh-compatible; unlimited command history

  • Tcsh/Csh: C shell; interactive login shell;
  • Ksh: Korn shell; interactive command language
  • Zsh: designed to be interactive; includes many indexes not in other shells (variable, function, key)
  • fish: user friendly shell; web based configuration; auto suggestion 1.2 common shell modes - Correct Answer-$ normal user prompt

root user prompt

-- = posix mode makes bash emulate sh, this will disable the operation sudo = auto to root 2.1 Where is command history saved to in bash? - Correct Answer-- command history is saved to ~./.bash_history, accessible by pressing the up arrow key

  • writes history from memory (HISTSIZE) to disk (HISTFILESIZE) when close the shell 2.1 How to create, read, copy, remove, change ownership, change permissions in bash and IMP commands - Correct Answer-create: touch read: cat copy: cp remove: rm change ownership: chown change permissions: chmod list: ls list w/ more detail on a file : ls -l FILENAME ps : process list system informaion (kernal/hardware) : uname -a help: --help go to the home: cd show current directory: pwd show date: date who am I logged in as: whoami ping host: ping

2.3 Piping - Correct Answer-used to put output of a process into another process [process 1] | [process2] named pipes: info remains in the named pipe until system is shut down mkfifo [pipeName] EX: ls -l text.txt | grep "Modify" 2.4 bash boolean logic - Correct Answer-! logical negation || OR && AND -o logical OR -a logical AND All values are either True or False / 0 or 1 XOR 2.5 methods of gaining more information about commands - Correct Answer-man [command] use to find info about a command apropos -r [description]

search man pages for a command whatis [command] returns a one line description [command] --help displays a quick help info [command] you cannot find what you need in man 3.1 Describe file system hierarchy (important directories) - Correct Answer-Everything stems from root / /bin essential command binaries /boot boot loader files /dev device files /etc host specific config files /home home directories /lib libraries for the binaries /media mounts removable media /mnt temporarily mounted fs

ls -l = this tell you information about the file 3.3 Describe the file system permissions - Correct Answer-ls -l [fileName]

  • read (r), write (w), execute (x) file system timestamps - Correct Answer-- Access: last time file was read
  • Modify: last time file content was modified
  • Change: last time meta data of the file was changed (i.e. permissions) file system attributes - Correct Answer-use +[attr] to set and -[attr] to clear: a append only c compressed d not backed up to a dump h blocksize storing i immutable j journaling s blocks are zeroed t no tail merging u undeletion

v version A no atime record D changes writing to disk E file using extent format I indexed directory S contents written synchronously T top of directory hierarchy X raw contents of compressed file Z indicates a compressed dirty file commands for searching file system - Correct Answer-$find [path] - [options] [expression] Use grep to add search for content: find [path] -[options] | grep "somestring" -B before the expression -A after the expression Awk is used to find/replace text or perform a specific action on the text -F specify the field separator how to create regular expressions - Correct Answer-. single character

  1. Kernel: mounts the root file system; executes /sbin/init/; initrd is used by kernel as a temp root filesystem until the real root file system is mounted post kernel linux boot process - Correct Answer-5. Init: identifies default initlevel; decides Linux run runlevel 0- halt (shutdown) 1- single user 2- multiuser safemode 3- multiuser w/ networking 4- unused 5- multiuser w/ GUI 6- reboot 6: Runlevel: runlevel programs exexutes the programs from /etc/rc#.d/ where # = run level differences in boot processes across linux variants - Correct Answer- SysV Init vs Systemd SysV Init has PID = 1; starts at startup and runs till shutdown; if it can't start the systems enters Kernel panic mode. SystemD also had PID= buts runs in background and initiates parallel daemons so boot up is shorter. UEFI vs MBR:

UEFI uses GPT so you can have unlimited paritions and is filesystem aware what is a partition - Correct Answer-logically divides a hard disk; standard is 4 components of the boot configuration file - Correct Answer-/boot/ boot.0300 backup mbr boot.b basic boot sector chain.b for non linux os config-[kernel-version] installed kernel configuration os2_d.b boot the OS/ system.map location of the kernel vmlinux symbolic link to the kernel initrd.img temporary file system grub GRUB config files device.map maps devices in /dev to those used by grub grub.conf GRUB conf file messages welcome message splash/xpm.gz boot-up background image efi uefi bootloader

unattended-upgrades x11-common PIDs for common processes - Correct Answer-Userspace processes must have PID > 1000 (threads can have < 1000); init has pid=1 (All orphans have PPID=1) Bash commands to enumerate processes - Correct Answer-ps -aux for whole system ps for shell ps -ef for system services ps -o "%[column]" for specific column pwdx gets current working directory of processes explain the functionality of daemons - Correct Answer-Program that run in the background waiting to be activated by an event/condition that is instantiated as a process. PPID is 1 (init). Usually they are created by forking and killing the parent. orphaned processes - Correct Answer-- child process whose parent exits with the child still running

  • they are adopted by init

defunct/zombie processes - Correct Answer-- child process waiting on parent to read its exit status;

  • listed in process table but uses no CPU Apt/Aptitude - Correct Answer-- Apt is the Debian package manager. It is text-based and run from the command line
  • looks for sources in /etc/apt/sources.list
  • Aptitude is a front-end that allows users to interactively manage packages based on ncurses library aptitude [action] [packageName] apt-get [action] [packageName] evaluate the validity of Linux processes - Correct Answer-- validate that that Orphan processes are actually Orphans
  • check that processes under init.d should be there
  • look for switched letters in the process name
  • look for connections it could be making using netstat -ano
  • look from what directory it is running
  • look at how cron and as for scheduling shell scripting basics - Correct Answer-- everything is a string in bash

string manipulation - Correct Answer-column column -ts [separator] [file] awk awk [command] [$value] convert tabs expand [option] [file] merge lines q [option] [file] join lines join [option] [file1] [file2] length echo $(#var) substring $(string:position:length) substitution tr remove cut [option] [file] hashing - Correct Answer-- verifies integrity

  • commands: md5sum, sha1sum, sha512sum bash script enumeration of a Linux machine - Correct Answer-current name servers cat /etc/resolve.conf local users cat /etc/passwd password hashes cat /etc/shadow kernel version uname -a running processes ps aux current user/groups id who is connected w last logged on last -a

last system boot dmesg usb devices lsusb cpu info lscpu hardware info lshw hostname hostname -f ip address ip addr show; ifconfig -a network interfaces cat /etc/network/interfaces acls iptables listening ports netstat -ano groups cat /etc/group installed packages dpkg -l local name resolution in Linux - Correct Answer-- stored in the /etc/hostname filename

  • referenced using the hostname command
  • name resolution sources are stored in the /etc/hosts file (looks up DNS servers)
  • DNS servers are declares in the /etc/resolv.conf file nslookup standard vs raw sockets - Correct Answer-Standard sockets- payload is automatically encapsulated in a chosen transport protocol (TCP, UDP); user is unaware of the protocol headers

analyze network connections from command line - Correct Answer-ss | less ss -[t| u] ss -ltn ss -s system logs - Correct Answer-system log files contain events logged by operating system components such as device changes, system errors, startup messages, abnormal shutdowns linux application logs - Correct Answer-apps create logs in /var/log audit and authorization logs - Correct Answer-authentication logs: when someone logs in/out /var/log/auth.log contains logins and authentication methods used /var/log/wtmp contains current login info authorization: when someone tries to access an object/resource /var/log/audit contains logs stored by auditd daemon what to look for in Linux logs for security incidents - Correct Answer-"authentication failure";"failed password"

"password changed"; "new user" "failed su" "deny inbound"; "access-list...denied" "user priv level changed"; "user...locked out" define permanent presence - Correct Answer-maintains a persistent foothold in the system types of rootkits - Correct Answer-- application level: change/replace standard apps with rootkit operations

  • kernel level: replace portions of or add to the core operating system
  • firmware: hide in hardware
  • hypervisor level: hosts the target OS as a virtual machine, intercepting hardware calls
  • boot loader level: replaces or modifies the legitemate bootloader Linux rootkits are usually either referred to as User and Kernel mode rootkits: User Mode: replace executables and system libraries that system admins and user use