Stuart Linux Flashcards
Augment: Display more details about files in current directory.
ls -l
Augment: Display all files(even the hidden ones)
ls -a
How do you find out a file type of a file?
file
While using the less command how would you find the word “server3”
/server3
How would you copy the file test.1 to /home/bin
cp test.1 /home/bin
Augment: how would you copy a directory “dir1” to /home/lib
cp -r dir1 /home/lib
How would you search for a file named networkinfo.txt throughout the system and again through the /home/bin folder
find / -name networkinfo.txt
find /home/bin -name networkinfo.txt
How would you output the list of objects in your current directory to the sample.txt file
ls > sample.txt
> Overwrites
» adds the output to the end
How would you see what the home directory is?
echo $home or env
How would you extract the 10 character from each line of sample.txt? how about the 3rd field?
cut -c 10 sample.txt
cut -f 3 sample.txt
How would you sort sample.txt alphabetically and numerically?
sort
sort -n
How do you get the character/word/line count of a file
wc (-c/w/l)
this command add numbers beside each line
nl
This lets you search for words or numbers in a file. also how do you make it case insensitive
grep
grep -i
how to VIM edit a file
VIM file
how to enter insert mode
i
how to copy a letter/line in VIM
y for a character and yy for a line
how to delete in vim
d in command mode delete or backspace otherwise.
in VIM how to get out of insert mode
esc
how to paste in VIM
p
in VIM how to save
:w
in VIM how to quit
:q
or :q! to quit without saving
how to save and exit in VIM
:wq or ZZ
Location of where user information is held
/etc/passwd
Location of password information
/etc/shadow
Location of where group information is.
/etc/group
What command changes default permissions to files
Umask
How would you change default permissions to new files to makes user have RWE, RW, and RE
Umask 012
How would you add a Suid to a file?
chmod 4755(755 generic) filename
How would you add a Gid to a file?
chmod 2755(755 generic) filename
what does ps aux do and what does aux stand for?
reveals detailed process information.
A - ps for all users
U - Detailed information
X - lists processes without a TTY
What does a TTY of “?” entail
? means it is a daemon that starts on boot and is terminated on shutdown. other TTY’s are associated with terminal instances and can come and go.
How would you stop a process
ps u to find the PID
then kill PID
How would you zip a file?
tar cvf “new file name” “files you want to zip” “file2 you want to zip”
c - create
v - tell the program to be verbose and let us see what it’s doing
f - the filename of the tar file has to come after this option, if you are creating a tar file you’ll have to come up with a name
How would you unzip a file?
tar xvf
x - extract
v - tell the program to be verbose and let us see what it’s doing
f - the file you want to extract
How would you unzip the file “myfile.tar.gz” explain
tar xzf myfile.tar.gz - usually XVF works, however since the file has a .gz zip it needs to unzip with gunzip 1st. the “z” option unzips with gunzip 1st.
What are Debian and RPMs package managers that do not deal with dependencies?
Debian - dpkg
RPM - RPM
What are Debian and RPMs package managers that deal with dependencies?
Debian - APT
RPM - YUM
List all devices and explain what each of the four 1st bits of each line could mean
ls -l /dev
c - Character - not a physical device, increases functionality of system.
b- Block - These devices transfer data, but in large fixed-sized blocks. You’ll most commonly see devices that utilize data blocks as block devices, such as hard drives, filesystems, etc.
p - Pipe - Named pipes allow two or more processes to communicate with each other, these are similar to character devices, but instead of having output sent to a device, it’s sent to another process.
s - Socket - Socket devices facilitate communication between processes, similar to pipe devices but they can communicate with many processes at once.
Directory where more detailed device information is?
/sysfs
Systems that automatically adds, removes and manages devices
udev
how to list only 1 of the 3 types of devices (list all 3)
lspci
lsscsi
lsusb
Directory: Essential ready-to-run programs (binaries), includes the most basic commands such as ls and cp.
/bin
Directory: Contains kernel boot loader files
/boot
Directory: Device files.
/dev
Directory: Core system configuration directory, should hold only configuration files and not any binaries.
/etc
Directory: Personal directories for users, holds your documents, files, settings, etc.
/home
Directory: Holds library files that binaries can use.
/lib
Directory: Used as an attachment point for removable media like USB drives.
/media
Directory: Temporarily mounted filesystems.
/mnt
Directory: Optional application software packages.
/opt
Directory: Information about currently running processes.
/proc
Directory: Information about the running system since the last boot.
/run
Directory: Contains essential system binaries, usually can only be ran by root.
/sbin
Directory: Site-specific data which are served by the system.
/srv
Directory: Storage for temporary files
/tmp
Directory: This is unfortunately named, most often it does not contain user files in the sense of a home folder. This is meant for user installed software and utilities, however that is not to say you can’t add personal directories in there. Inside this directory are sub-directories for /usr/bin, /usr/local, etc.
/usr
Directory: Variable directory, it’s used for system logging, user tracking, caches, etc. Basically anything that is subject to change all the time.
/var
this is a command line tool that supports both MBR and GPT partitioning
parted
this is the GUI version of parted
gparted