Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
154 Cards in this Set
- Front
- Back
display all running process
|
ps aux | less
-A: select all process a: select all process on a terminal x: select processes without controlling |
|
to see every process on the system
|
ps -A
ps -e |
|
See every process except those running as root
|
ps -U root -u root -N
|
|
to display a debug view of running processes
|
top
|
|
display tree of processes
|
pstree
|
|
process tree using ps
|
ps -ejH
ps axjf |
|
security info
|
ps -eo euser,ruser,suser,fuser,f,comm,lablel
ps axZ ps -eM |
|
save process snap shot to a file
|
top -b -n1 > /tmp/process.log
|
|
mail process snapshot to a file
|
top -b -n1 |mail -s 'Process snapshot' you@me.com
|
|
lookup process
|
pgrep firefox
|
|
list the process called sshd which is owned by router
|
pgrep -u root sshd
|
|
ls -l | less
|
In this example, ls is the Unix directory lister, and less is an interactive text pager with searching capabilities. The pipeline lets the user scroll up and down a directory listing that may not fit on the screen.
|
|
curl "http://en.wikipedia.org/wiki/Pipeline_(Unix)" | \
sed 's/[^a-zA-Z ]/ /g' | \ tr 'A-Z ' 'a-z\n' | \ grep '[a-z]' | \ sort -u | \ comm -23 - <(sort /usr/share/dict/words) | \ less |
curl obtains the HTML contents of a web page (could use wget on some systems).
sed removes all characters that are not spaces or letters from the web page's content, replacing them with spaces. tr changes all of the uppercase letters into lowercase and converts the spaces in the lines of text to newlines (each 'word' is now on a separate line). grep includes only lines that contain at least one lowercase alphabetical character (removing any blank lines). sort sorts the list of 'words' into alphabetical order, and the -u switch removes duplicates. comm finds lines in common between two files, -23 suppresses lines unique to the second file, and those that are common to both, leaving only those that are found only in the first file named. The - in place of a filename causes comm to use its standard input (from the pipe line in this case). sort /usr/share/dict/words sorts the contents of the words file alphabetically, as comm expects, and <( ... ) outputs the results to a temporary file (via process substitution), which comm reads. The result is a list of words (lines) that are not found in /usr/share/dict/words. less allows the user to page through the results. |
|
bash
|
the gnu borne again shell is based on the earlier bourne shell for unix. Common default shell for user accounts
|
|
bsh
|
the bourne shell upon which bash is based also goes by the name of bsh
|
|
tsch
|
based in earlier c shell(csh). Its fairly popular in some circles, but no major linux distribution make it the defaul shell. Although it's similar to bash
|
|
csh
|
the original C shell
|
|
ksh
|
the Korn shell was designed to take the best feature of the Bourne shell and the C shell and extend them further
|
|
zsh
|
the z shell takes shell evolution further than the ksh incorporating feature from earlier shells and adding still more
|
|
/bin/sh use
|
is a symbolic link to the system's default shell - normally /bin/bash
|
|
Linux cmd are ______
|
external
they are separate programs from the shell. few cmd are internal to the shell |
|
xterm or konsole cmd
|
this will launch an xterm-type program that will rin a shell
|
|
internal shell cmd
shell and running directory |
built into the shell
whenever you are running a shell it is in a specific directory |
|
Directory
/ /bin /boot |
/ - represents the root directory of the Linux system
/bin - contains binary cmd taht are available to all users /boot - contains the kernel and boot loader |
|
cd cmd
pwd cmd |
changes the current dir
displays the current working directory |
|
cd ~
|
the tilde ~ character us a short cut, that stands for your home dir
cd ~ same as cd /home/sally |
|
Directory
/dev /etc /home |
/dev - contains device files
/etc - contains configuration files specific to the system /home - contains default user home directories |
|
echo <test string>
|
causes the system to display the <text string>
|
|
exec <myprog>
|
the exec cmd runs an external program that you specify under <myprog> but keep in mind that using the exec cmd causes the current shell process with the <myprog> process
|
|
time <other cmd> cmd
|
the time cmd times how long subsequent cmd tale to execute
example: time pwd tells you how long the system took to execute the pws cmd |
|
directory
/initrd /lib /media |
/initrd - dir is used during the boot process to hold the initial RAM
/lib - contains shared probram libraries and kernel modules /media - contains the /cdrom and /floppy dir |
|
logout cmd
exit cmd |
terminates the shell
but only the login shell exit - terminates the shell |
|
How you execute an external cmd that matches an internal cmd
|
the internal cmd takes precedence unless you provide the complete path to the external cmd on the cmd line as in typing /nin/pwd rather than pwd
|
|
sudo /usr/sbin/dmidecode | less
|
info about the moder board and other hardware configurations
|
|
Environmental variables in Linux
|
they can be sat in bash by using the = operator followed by the export cmd
$NNTPSERVER-news.abifisp.com $export NNTPSERVER set NTTPSERVER to url |
|
directory
/mnt /opt /proc |
/mnt - an empty dir. used to be the mount point fro mount cmd
/opt - contains additional programs /proc -contains information about the system state and processes |
|
unset cmd
|
to delete an environmental variable use
unset >name var> |
|
man man cmd
env cmd |
description of the man cmd
displays a list of environmental variables |
|
man section numbers
|
1 - exec programs and shell cmd
2 - system class provided by the kernel 3 - library calls provided by program libraries 4 - device files 5 - file formats 6 - games 7 - miss 8 - system administrator commands 9 - kernel reoutines |
|
info info
once in man mode press q |
some cmd have moved away from man pages and replaced them with http
quites the man/info mode |
|
streams
|
Linux treats the input to and output form programs as a stream, which is a data entity that can be manipulated
|
|
directory
/sbin /root /srv |
/sbin - contains binary system cmd
/root - root user's home dir /srv - contains files for services like the FTP and Web Server |
|
stdout
stderr |
standard output stream
standard error stream |
|
> cmd
>> cmd |
> re-director operator that creates a new file containing standard output. if the specified file exist it is overwritten
>> redirector operator that appends standard output to the existing file |
|
/sys
/tmp /usr |
/sys - takes some of the system state
/tmp - contains temporary files created by programs /usr - contains system cmd and utils |
|
2> cmd
2>> cmd |
2> redirector operator that create a new file containing standard error
2>> redirector operator that appends to file containing standard error |
|
&> cmd
< cmd |
&> - redirector operator that creates a new file containing both stdout and stderr
< - Sends the contents of the specified file to be used as standard input |
|
File Type (special) - Symbolic Link
File Type (special) - Character File Type (special) - Block |
File Type (special) - Symbolic Link - is a file system entry that point to another file system entry
File Type (special) - Character - File Type (special) - Block |
|
<> cmd
|
causes the specified file to be used for both standard input and standard output
|
|
netstat -t -u
netstat -t -u -c |
display only tcp and udp connections
-c continuous |
|
clear screen cmd
|
clear
|
|
tee cmd
|
this cmd splits standard input so that it's displayed on standard output and on as many file as you specify example
someprog | tee output.txt |
|
data pipes
|
first | second
|
|
deleting all of the backup files denoted by the ~ char
|
find ./ -name
*~" | xargs rm the first part of this cmd find all the files in the current directory or its subs with a name that ends in a ~. This list is then piped to xargs, which adds each one to its own rm cmd |
|
backtick `
|
text within backticks is treated as a separate cmd whose results are substituted on the cmd line
rm `find ./ -name "*~" |
|
cat cmd + example
|
it links together an arbitrary number of files end to end and sends the result to standard output
cat first.txt second.txt > combined.txt |
|
cat cmd second use
|
although cat is officially a tool for combining files, its also commonly used to dusplay the contents of a short file.
|
|
cat display line ends
|
if you want to see where lines end, add the
-E or --show-ends the result is an % sign at the end of each line |
|
cat number lines
|
-n
--number option adds line number to the beginning of every line |
|
cat number only non empty lines
|
-b
--number-nonblank option adds line number to the beginning of meaningful lines skipping lines containing empty space |
|
cat minimiza blank line
|
-s
--squeeze-blanks compresses groups of blank line down to a single blank line |
|
xargs cmd description
|
with xargs you can combine the output of two or more different cmds
example trying to remove all files ending with ~ in a directory structure use find to find the files than rm to remove the files |
|
xargs cmd syntax
|
xargs [option] [command [initial-arguments]]
initial arguments - list of arguments you want to pass to the cmd |
|
xargs cmd example
delete all files ending with ~ |
find ./ -name "*~" | xargs rm
|
|
cmd to find all files in the current directory (./) and its sub directories with a name that ends with ~
|
find ./ -name "*~"
|
|
back tick ` char usage
|
similar to the xargs
text within back-ticks is treated as a separate cmd whose results are substituted on the cmd line rm `find ./ -name "*~"` |
|
join cmd
|
combines two files by matching the contents of specified fields within the files. Usually space, comma, tab separated files
f1 555 david 666 dimittar f2 555 beckham 666 berbatov join f1 f2 555 david beckham 666 dimitar berbatov |
|
join cmd -i switch
|
ignores case sensitivity
|
|
join cmd -t switch
|
specify another separator instead of space
|
|
join cmd -1 -2 switch
|
by default join uses the first field as key
by specifying number -1 3 -2 4 specifies to make a match on between the 3rd field from first file and 4th field from second file |
|
paste cmd
|
merges files line by line
separate the lines each file with tabs |
|
converting tab to spaces cmd
|
expand
by default tab is every 8 chars with -t num you specify num for tab length |
|
displaying files in octal cmd
|
od filename
(comes from octal dump) |
|
sorting files cmd
|
sort
|
|
sort cmd switch for ignoring case when sorting
|
-f
--ignore-case by default sorts bu ASCII value, which makes difference between upper and lower case letters |
|
sort cmd switch for sorting by 3 letter month
|
-M
--mont-sort |
|
sort cmd switch for sorting by number
|
-n
--numeric-sort |
|
sort cmd switch for sorting in reverse order
|
-r
--reverse |
|
sort cmd switch for sorting field
|
-k field
--key=field by default sort uses the first field as its sort field |
|
cmd to break file in peace
|
split
requires on output filename and how large each split is to be |
|
split cmd switch for splitting by bytes
|
-b size
--bytes=size This option can usually have an undesirable consequence of splitting file mid line |
|
split cmd option for splitting a file in line size chunks
|
-C=size
--line-bytes=size |
|
split cmd option for splitting a file based on number of lines
|
-l lines
--lines=lines |
|
cmd for translating characters
|
tr [options] SET1 [SET2]
set1 - chars you want to replaces set2 - chars to replace with each char from set1 is match to corresponding char from set2 |
|
cmd to convert spaces to tabs
|
unexpand
-t num --tabs=num sets tab spacing |
|
cmd to delete duplicate lines
|
uniq
sort f1.txt | uniq |
|
cmd to reformat text files, such as man files having too long lines
|
fmt
|
|
cmd to number lines in of a file
|
nl
|
|
cmd that formats a document in pages suitable for printing
|
pr
|
|
nl cmd option for body numbering style
|
-b style
--body-numbering=style |
|
nl cmd option for header and footer numbering style
|
-h style
-header-numbering=style -f style -footer-numbering=style the text needs to be formatted for printing |
|
nl cmd option to reset numbering on each page or other condition
|
-d=code
--section-delimiter=code options where code is a code for the character delimiting the pages |
|
nl cmd option for renumbering a new page
|
-p
--no-renumber option |
|
nl cmd option to send number format
|
-n format
--number-format=format Where format ln - left rn - right rz - right with leading zeroes |
|
nl cmd option to number only non-blank line
|
the default behavior
corresponds to style of t |
|
nl cmd option to number all line
|
style of a
|
|
nl cmd option to number no lines
|
style of n
|
|
cmd to print a plain text file
|
pr filename.txt
|
|
cmd to see the first 10 lines of a file
|
head
|
|
head cmd option to display the first num bytes of a file
|
head
-c num --bytes=num |
|
head cmd option to display the first num lines of a file
|
head
-n num --bytes=num |
|
cmd to display the last 10 lines of a file
|
tail
|
|
tail -c
tail -bytes -------------- tail -n tail -line |
changes the amoun of data displayed
|
|
tail -f
tail --follow |
keeps the file open and displays new lines as they are added
|
|
tail -pid=pid
|
tells tail to terminate tracking
|
|
cut -b
cut --byre=list |
cuts the specofoed list of bytes from the input file
|
|
cut -c
cut --charlist=list |
cuts the specified list of characters from the input file
|
|
cut -f
cut --fileds=list |
cuts the specified list of fields from the input file
|
|
cmd/script tp get the MAC address of eth0
|
ifconfig ethh0 | grep HWaddr | cut -d " " -f 11
|
|
cmd to obtain count of bytes in file
|
wc file.txt
|
|
cmd and switch to count the new lines
|
wc --lines
wc -l |
|
cmd and switch to coumt
words bytes chars |
wc --words
wc -w --------------- wc --bytes wc -b --------------- wc --char wc -m |
|
get linux version
|
$ cat /etc/*-release
|
|
list running deamons
|
ps aux
|
|
/proc filesystem
|
when adding new hardware to an existing Linux system, you may wish to verify which resources the existing devices are using.
/proc filesystem, the kernel's status repository contains this info pric files, interrupts, dma and ioreports show how system resources are currently used cat /proc/interrupts |
|
how to get list of interrupts
|
CPU0
0: 80448940 XT-PIC timer 1: 174412 XT-PIC keyboard 2: 0 XT-PIC cascade 8: 1 XT-PIC rtc 10: 410964 XT-PIC eth0 12: 60330 XT-PIC PS/2 Mouse 14: 1314121 XT-PIC ide0 15: 5195422 XT-PIC ide1 NMI: 0 ERR: 0 |
|
Use this utility to see the contents of a compressed file
End of File (EOD) character used to close a file? |
catz
CTRL - D |
|
You want to display the file June_report with the less pager, highlighting places where the word "data" appears. What command do you user?
|
less +/data June_report
|
|
What does Linux use to communicate with MacOS resources?
What protocol dose Samba use to communicate with Microsoft resources? What two protocols were created to replace SMB? |
Netatalk
SMB CIFS nad |
|
When searching man pages
"x" searches the description; "y" stings searches the entire contents of the man pages; "z" string finds all matching entries |
x="-k"
y="-K" z="-a" |
|
Why can all users change their passwords even though only the owner can write to passwd?
|
passwd uses setuid to set permissions when it is running
|
|
What numeric value does write permission have?
What numeric value does execute permission have? |
write - 2
execute - 1 |
|
In ipchains, what is the difference between deny and reject?
|
reejct notifies the sender; deny does not
|
|
Waht two advantages does ReiserFS have over ext2?
|
faster recovery from errors and faster and more secure hard drive writes
|
|
Dynamically linked executable
|
examined at runtime by the shared object dynamic linker, ld.so
ld.so - looks for dependencies in the executable being loaded and attempts to satisfy any unresolved links. if ld.so cant fined the specified library it fails to execute the application |
|
to find a new library lo.sd must be instructed to look in
|
/usr/local/lib
2 ways it can be done 1)add a colon-separated list of dir to the shell environment var LD_LIBRARY_PATH 2)add new lib entry to the cache by first adding the entry to /etc/ld.so.conf which contains the dir to be indexed by the ldconfig utility |
|
/usr/local/lib
2 ways it can be done 1)add a colon-separated list of dir to the shell environment var LD_LIBRARY_PATH 2)add new lib entry to the cache by first adding the entry to /etc/ld.so.conf which contains the dir to be indexed by the ldconfig utility |
ldconfig [options] libs_dirs
Update the ld.so cache file with shared libraries specified on the command line in lib_dirs, in trusted directories /usr/lib and /lib and in the directories found in /etc/ld.so.conf -p - displays the current cache instead of recreating it -v - verbose mode, progress during execution |
|
What cmd will display default file permissions?
|
unmask
|
|
erase all other permissions and then add just read and write permissions to the projectX group on a file
|
cd projectX
chmod g=rw <filename> |
|
change file permissions for a group to simply read permissions
|
cd groupname
chmod g-w chmod g+r (g-w takes away the write permissions) |
|
show/list all the permissions or 'modes' a user has
|
ls -l username
r = read w = write x = execute |
|
check to see all the groups bob is member of
|
groups bob
|
|
create a group called projectX then add users to that group check your work
|
groupadd -r ProjectX
usermod -g ProjectX bob,candy cat /etc/group |
|
Create an alias for the commonly used remove function
Completely remove a user (this will not remove all the user files saved but will remove all user info) show the dir for your newly created password |
alias rm=rm -i
userdel -r joe cat /etc/shadow |
|
Where is group information kept
check to see the comment was added to joe's name list all of joe's newly created files |
cat /etc/group
cat /etc/passwd ls -a joe |
|
What character is used in a filename to specify a backup file
How would you find every occurrence of the word dog n a file called pets (case insensitive)? |
~
grep -iw dog pets |
|
You want to get a list of all the directories in your home directory stored by time with the newest level at the top. What cmd would you use?
|
ls -tdR *
|
|
If you know the name of the file you want to extract, you can pass it directly to tar using this option?
|
tar -xf myarchive.tar myfile
|
|
To create a tar file of the PWD use the "-xy" option?
(where "x" create the tar file "y" give the name for the new archive) |
-cf
|
|
to permanently change your shell, use this cmd
|
chsh -s shellname
|
|
use the -"wxyz" option with tar to extract files in interactive mode
You can view the contents of your tar file using -"xy" option? (where "x" causes tar to print the names of the tar files) |
-xvwf
-tf |
|
as part of your backup strategy you want to back up the /home dir to /backups on another partition. What would you type at the cmd line?
|
tar -cf /backup/homebackup.tar home/*
|
|
show cmd to create a tar file called myarchive.tar in the PWD & gzip it
|
tar -cf myarchive.tar . | gzip myarchive.tar
|
|
By default emacs config is kept here?
|
/etc/inputrc
|
|
you can uncompress a gzip file using these 2 methods
|
gzip -d
gunzip |
|
Which cmd would you use to check the value for the variable DISPLAY?
To change a path for all users edit this file? Where must aliases be entered for system wide use? |
echo $DISPLAY
/etc/profile /etc/bashrc |
|
To make the change in your prompt permanent edit 1 of these files?
What cmd would you type to temporary add the date/time to your shell prompt? |
.bash_profile
or .profile ------------------- PS1='Date: \d Time: \t->>'; export PS1 |
|
This utl lets you look at running processes, stats on memory & the swap file?
|
top
|
|
Use this cmd to suspend a running program & put it in the background?
Use this command to bring back to foreground? Use this to kill the process? |
CTRL+Z
fg CTRL+C |
|
File Type - Directory
File Type - Normal File |
File Type - Directory - A file type designed specifically to hold or point to other file types.
File Type - Normal File - Every file that is not a directory is generally a normal file. |
|
File Type (special) - Hard Link
|
A hard link is a duplicate entry in the file system that points to a specific piece of data. Hard links are not often used. If the original entry in the file system is deleted, the hard link maintains a valid pointer to the data.
|
|
File Type (special) - Symbolic Link
|
A symbolic link is a file system entry that points to another file system entry, which in turn points to a valid piece of data. Symbolic links can work across volumes and file systems. Symbolic links are similar to shortcuts in Windows.
|
|
File Type (special) - Character
|
A file type that accepts input one character (i.e., byte) at a time. Character files often point to devices like sound cards, serial ports, or video port.
|
|
File Type (special) - Block
File Type (special) - Pipe |
File Type (special) - Block - A file type that accept input in blocks (i.e., groups of bytes). Block files often point to storage devices.
File Type (special) - Pipe - A named pipe file allows you to send information between applications. |