# on 10-Oct-2018 (Wed)

#### Flashcard 3415793601804

Question
In Linux, how do you run a command, e.g. ls -la /bin/, in the backgroup and make sure it continues running even if you log out?
nohup ls -la /bin/ &
^^nohup ensure that the SIGHUP(terminate signal) is ignored (i.e. even if terminal is closed/you log out), & runs command in backgroud

status measured difficulty not learned 37% [default] 0
4. Basic Commands
sense later.) lynx <url> Opens a URL [URL stands for Uniform Resource Locator--a web address.] at the console. Try lynx http://lwn.net/ . links <url> Another text-based web browser. <span>nohup <command> & Runs a command in the background, appending any output the command may produce to the file nohup.out in your home directory. nohup has the useful feature that the command will continue

#### Flashcard 3415796747532

Question
In linux, what is command to sleep for 10 seconds?
sleep 10

status measured difficulty not learned 37% [default] 0
4. Basic Commands
roduce to the file nohup.out in your home directory. nohup has the useful feature that the command will continue to run even after you have logged out. Uses for nohup will become obvious later. <span>sleep <seconds> Pauses for <seconds> seconds. See also usleep . sort <filename> Prints a file with lines sorted in alphabetical order. Create a file called telephone with each line containi

#### Flashcard 3415799893260

Question
In Linux, you have file, kevin.txt, how do you print out the lines on cmd terminal in reverse (last line first, first line last)?
tac kevin.txt
^^ note: tac is cat in reverse:)

status measured difficulty not learned 37% [default] 0
4. Basic Commands
B pieces. Its sister, csplit , can split files along specified lines of text within the file. The commands are seldom used on their own but are very useful within programs that manipulate text. <span>tac <filename> [<filename> ...] Writes the contents of all the files listed to the screen, reversing the order of the lines--that is, printing the last line of the file first. t

#### Flashcard 3415803038988

Question
In Linux, if you are viewing a live log, log.txt, what is best command to view the last 10 lines of that log file, in real time?
tail -n 10 -f log.txt
^^ note -f will keep showing lines at end of log file, as they get appended, in real time

status measured difficulty not learned 37% [default] 0
4. Basic Commands
...] Writes the contents of all the files listed to the screen, reversing the order of the lines--that is, printing the last line of the file first. tac is cat backwards and behaves similarly. <span>tail [-f] [-n <lines>] <filename> Prints the last <lines> lines of a file or 10 lines if the -n option is not given. The -f option means to watch the file for lines being a

#### Flashcard 3415806184716

Question
In Linux, if you have file, kevin.txt, how do you get the number of lines this file has?
wc -l kevin.txt

status measured difficulty not learned 37% [default] 0
4. Basic Commands
> Prints a file with duplicate lines deleted. The file must first be sorted. usleep <microseconds> Pauses for <microseconds> microseconds (1/1,000,000 of a second). wc [-c] [-w] [<span>-l] <filename> Counts the number of bytes (with -c for c haracter), or words (with -w ), or lines (with -l ) in a file. whatis <command> Gives the first line of the man page co

#### Flashcard 3415809330444

Question
In Linux, you have file, kevin.txt, how do you get the number of words, chars, and lines this file has?
wc kevin.txt

status measured difficulty not learned 37% [default] 0
4. Basic Commands
q <filename> Prints a file with duplicate lines deleted. The file must first be sorted. usleep <microseconds> Pauses for <microseconds> microseconds (1/1,000,000 of a second). <span>wc [-c] [-w] [-l] <filename> Counts the number of bytes (with -c for c haracter), or words (with -w ), or lines (with -l ) in a file. whatis <command> Gives the first line of t

#### Flashcard 3415812476172

Question
In linux, how do you print out name of current user?
whoami

status measured difficulty not learned 37% [default] 0
4. Basic Commands
es (with -l ) in a file. whatis <command> Gives the first line of the man page corresponding to <command> , unless no such page exists, in which case it prints nothing appropriate . <span>whoami Prints your login name. 4.10 The mc File Manager Those who come from the DOS world may remember the famous Norton Commander file manager. The GNU project has a Free clone called the Mid

#### Flashcard 3415815621900

Question
In Linux, if you run a process from the prompt, how do you kill that same process from the same prompt (e.g. you run "sleep 100" but want to exit it before 100 seconds)?
ctrl-c

status measured difficulty not learned 37% [default] 0
4. Basic Commands
nuously. You must type this at the same prompt where you entered the command. If this doesn't work, the section on processes (Section 9.5) will explain about signalling a running application to <span>quit. 4.13 Compressed Files Files typically contain a lot of data that one can imagine might be represented with a smaller number of bytes. Take for example the letter you typed out. The wor

#### Flashcard 3415818767628

Question
In Linux, you have large files, kevin.txt, how do you compress this file?
gzip kevin.txt
^^gzip stands for GNU zip, and creates new file kevin.txt.gz

status measured difficulty not learned 37% [default] 0
4. Basic Commands
data by using a smaller number of bytes, in such a way that the original data can be reconstructed exactly. Such usually involves finding patterns in the data. The command to compress a file is <span>gzip <filename> , which stands for GNU zip. Run gzip on a file in your home directory and then run ls to see what happened. Now, use more to view the compressed file. To uncompress the file use gzip -d

#### Flashcard 3415821913356

Question
In Linux, if you use gzip to zip/unzip a file, what happens to the original file, e.g. what happens after you do gzip kevin.txt
kevin.txt gets replaced with kevin.txt.gz

status measured difficulty not learned 37% [default] 0
4. Basic Commands
uch a way that the original data can be reconstructed exactly. Such usually involves finding patterns in the data. The command to compress a file is gzip <filename> , which stands for GNU <span>zip. Run gzip on a file in your home directory and then run ls to see what happened. Now, use more to view the compressed file. To uncompress the file use gzip -d <filename> . Now, us

#### Flashcard 3415825059084

Question
In Linux, you have compressed file kevin.txt.gz, how do you unzip it?
gzip -d kevin.txt.gz
^^ -d is short for --decompress, above replaces kevin.txt.gz with kevin.txt
^^ also correct is: gunzip kevin.txt.gz

status measured difficulty not learned 37% [default] 0
4. Basic Commands
lt;filename> , which stands for GNU zip. Run gzip on a file in your home directory and then run ls to see what happened. Now, use more to view the compressed file. To uncompress the file use <span>gzip -d <filename> . Now, use more to view the file again. Many files on the system are stored in compressed format. For example, man pages are often stored compressed and are uncompressed automatically w

#### Flashcard 3415828204812

Question
In linux, you have zipped up file, kevin.txt.gz, how do you view its content without unzipping it?
zcat or zless

status measured difficulty not learned 37% [default] 0
4. Basic Commands
have a z in them they have something to do with compression--the letter z stands for zip. You can use zcat <filename> | less to view a compressed file proper. You can also use the command <span>zless <filename> , which does the same as zcat <filename> | less . (Note that your less may actually have the functionality of zless combined.) A new addition to the arsenal is bz

#### Flashcard 3415831350540

Question
In Linux, [...] is a newer version of gzip used for compressing larger files (but it is slower), but you should not use it if you are zipping/unzipping the file back and forth a lot.
bzip2

status measured difficulty not learned 37% [default] 0
4. Basic Commands
mand zless <filename> , which does the same as zcat <filename> | less . (Note that your less may actually have the functionality of zless combined.) A new addition to the arsenal is <span>bzip2 . This is a compression program very much like gzip , except that it is slower and compresses 20%-30% better. It is useful for compressing files that will be downloaded from the Interne

#### Flashcard 3415834496268

Question
In Linux, how do you search for all the very large files (e.g. all files over 50000K in size, suppose you are already in / dir)?
find . -size +50000

status measured difficulty not learned 37% [default] 0
4. Basic Commands
hat end in a .c extension ( find -name *.c without the quote characters will not work. You will see why later). find -name Mary_Jones.letter will find the file with the name Mary_Jones.letter . <span>find -size [[+|-]]<size> Finds only files that have a size larger (for + ) or smaller (for - ) than <size> kilobytes, or the same as <size> kilobytes if the sign is not specified. find <directory

#### Flashcard 3415837641996

Question
In Linux, the find command searches for files, directory by directory, a faster command, called [...] , uses a filedb.
locate

status measured difficulty not learned 37% [default] 0
4. Basic Commands
me> . This searches through a previously created database of all the files on the system and hence finds files instantaneously. Its counterpart updatedb updates the database of files used by <span>locate . On some systems, updatedb runs automatically every day at 04h00. Try these ( updatedb will take several minutes): 5 updatedb locate rpm locate deb locate passwd locate HOWTO locate RE

#### Flashcard 3415840787724

Question
In Linux, you have an ssh config file, called config, how do you search for and print out the 5 lines around the word "euqa-kc-backend-01"?
grep -5 euqa-kc-backend-01 config
^^ the -5 will print the 5 lines above and below the search word: euqa-kc-backend-01

status measured difficulty not learned 37% [default] 0
4. Basic Commands
isplay all lines containing it: grep 'the' Mary_Jones.letter . Now try grep 'the' *.letter . grep -n <pattern> <filename> shows the line number in the file where the word was found. <span>grep -<num> <pattern> <filename> prints out <num> of the lines that came before and after each of the lines in which the word was found. grep -A <num> <pattern> <filename> prints out <num>

#### Flashcard 3415843933452

Question
In Linux, you have file, kevin.txt, how do you print out all the lines that do NOT have the word "test"?
grep -v test kevin.txt
^^ -v is short for --invert-match

status measured difficulty not learned 37% [default] 0
4. Basic Commands
the lines in which the word was found. grep -B <num> <pattern> <filename> prints out <num> of the lines that came B efore each of the lines in which the word was found. <span>grep -v <pattern> <filename> prints out only those lines that do not contain the word you are searching for. [ You may think that the -v option is no longer doing the same kind of t

#### Flashcard 3415846554892

Question
In Linux, you have file, kevin.txt, how do you print all the lines that have word "test", case insensative?
grep -i test kevin.txt

status measured difficulty not learned 37% [default] 0
4. Basic Commands
h versatility that their functionality often overlaps with that of other commands. One actually never stops learning new and nifty ways of doing things hidden in the dark corners of man pages.] <span>grep -i <pattern> <filename> does the same as an ordinary grep but is case insensitive. 4.16 Copying to MS-DOS and Windows Formatted Floppy Disks A package, called the mtools packag

#### Flashcard 3415851011340

Question
In Linux, gzip command is used to zip/unzip a single file while [...] command is used to pack many files into one.
tar

status measured difficulty not learned 37% [default] 0
4. Basic Commands
n case of an emergency. When we want to store a number of files in this way, it is useful to be able to pack many files into one file so that we can perform operations on that single file only. <span>When many files are packed together into one, this packed file is called an archive. Usually archives have the extension .tar , which stands for tape archive. To create an archive of a directory, use the tar command: tar -c -f <filename> <directory> Create a directory with a few files in it, and ru

#### Flashcard 3415854157068

Question
In Linux, tar stands for [...] [...]
tape archive

status measured difficulty not learned 37% [default] 0
4. Basic Commands
file so that we can perform operations on that single file only. When many files are packed together into one, this packed file is called an archive. Usually archives have the extension .tar , <span>which stands for tape archive. To create an archive of a directory, use the tar command: tar -c -f <filename> <directory> Create a directory with a few files in it, and run the tar command to back it up.

#### Flashcard 3415857302796

Question
In Linux, you have bunch of images under /path/to/images/*.jpg, how do you create a tarball from them called jpegarchive.tar.gz?
tar -czvf jpegarchive.tar.gz /path/to/images/*.jpg
^^ -c is --create, -z is --gzip, -v is --verbose, -f is --file

status measured difficulty not learned 37% [default] 0
4. Basic Commands
ked together into one, this packed file is called an archive. Usually archives have the extension .tar , which stands for tape archive. To create an archive of a directory, use the tar command: <span>tar -c -f <filename> <directory> Create a directory with a few files in it, and run the tar command to back it up. A file of <filename> will be created. Take careful note of any error messages that tar reports. L

#### Flashcard 3415861234956

Question
In Linux, you have tar ball, backups.tgz, how do you unpack it?
tar -xzvf backups.tgz
^^ -x is --extract, -z is --gunzip, -v is --verbose, -f is --file

status measured difficulty not learned 37% [default] 0
4. Basic Commands
se the verify option (see the man page) of the tar command to check the integrity of <filename> . Now remove the directory, and then restore it with the extract option of the tar command: <span>tar -x -f <filename> You should see your directory recreated with all its files intact. A nice option to give to tar is -v . This option lists all the files that are being added to or extracted from the arc

#### Flashcard 3415864380684

Question
In Linux, a tarball (zipped up archaive), by convention has extension [...] or .tgz
.tar.gz

status measured difficulty not learned 37% [default] 0
4. Basic Commands
t option is -p which preserves detailed attribute information of files. Once you have your .tar file, you would probably want to compress it with gzip . This will create a file <directory><span>.tar.gz , which is sometimes called <directory>.tgz for brevity. A second kind of archiving utility is cpio . cpio is actually more powerful than tar, but is considered to be more cryptic

#### Flashcard 3415867526412

Question
In Linux, a tarball (zipped up archaive), by convention has extension .tar.gz or [...]
.tgz

status measured difficulty not learned 37% [default] 0
4. Basic Commands
ormation of files. Once you have your .tar file, you would probably want to compress it with gzip . This will create a file <directory>.tar.gz , which is sometimes called <directory><span>.tgz for brevity. A second kind of archiving utility is cpio . cpio is actually more powerful than tar, but is considered to be more cryptic to use. The principles of cpio are quite similar

#### Flashcard 3415870934284

Question
In Linux, [...] is the environment variable that stores the directories where executables are searched for (for example when you type "ls", which directories should be searched to locate this executable)?
PATH

status measured difficulty not learned 37% [default] 0
4. Basic Commands
in/cp , then the shell tries to run the named program, cp , out of the /bin directory. If you just type cp on its own, then it tries to find the cp command in each of the subdirectories of your <span>PATH . To see what your PATH is, just type echo $PATH You will see a colon separated list of four or more directories. Note that the current directory . is not listed. It is important that t #### Flashcard 3415874080012 Question In Linux, how do you add the directory /opt/gnome/bin to your environment PATH, from the command prompt, for example? Answer export PATH=/opt/gnome/bin:$PATH

status measured difficulty not learned 37% [default] 0
4. Basic Commands
at the current directory not be listed for reasons of security. Hence, to execute a command in the current directory, we hence always ./<command> . To append, for example, a new directory <span>/opt/gnome/bin to your PATH , do PATH="$PATH:/opt/gnome/bin" export PATH LINUX supports the convenience of doing this in one line: export PATH="$PATH:/opt/gnome/bin" There is a further command, which

#### Flashcard 3415877225740

Question
In Linux, if you want to run an executable, for example "test", from the current directory, how must you run it?
./test

status measured difficulty not learned 37% [default] 0
4. Basic Commands

#### Flashcard 3415883517196

Question
In Linux, if you have an executable, whose directory location is in the PATH env variable, what command lets you know what its full executable PATH is (e.g. that ls is /bin/ls)?
which ls

status measured difficulty not learned 37% [default] 0
4. Basic Commands
H . [This is more often true of Solaris systems than LINUX.] Typing which <command> locates the one that your shell would execute. Try: which ls which cp mv rm which which which cranzgots <span>which is also useful in shell scripts to tell if there is a command at all, and hence check whether a particular package is installed, for example, which netscape . 4.19 The -- Option If a fi

#### Flashcard 3415888235788

Question
In python, the [...] module provides more specialized, high performance alternatives for the built-in data types, and includes types such as deques, namedtuples, ChainMaps etc.
collections

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3415891381516

Question
In python, the collections module offers a [...] data structure, similar to lists, but where inserting items at the beginning is much faster.
deque
^^ pronounced "deck", short for double-ended queue

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3415894527244

Question
In python, for collections.deque objects, you remove items from end of deque by pop(), and beginning of deque by [...]
popleft()

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3415897672972

Question
In python, for collections.deque objects, you add items to end of deque by append() and to beginning of deque by [...]
appendleft()

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3415900818700

Question
In python, a useful feature of deques is that they support a [...] optional parameter that restricts the size of the deque and makes it ideally suited to a data structure known as a circular buffer (for stream buffering).
maxlen

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3415903964428

Question
In python if you have dq=collections.deque([1,2,3], maxlen=3), what does dq contain after you do dq.append(4)?
[2,3,4]

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3415907372300

Question
In python, the collections module has a class called [...] , which is like a dictionary but were the order of the items is preserved by order they were added.
OrderedDict

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3415910518028

Question
In python, the collections object has a [...] method that creates a dictionary where non-existing keys get a default value according to the default_factory function supplied.
defaultdict

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3415913663756

Question
In python, use the collections.defaultdict method to create a dictionay, dd, where all its keys will have a default/initial value of False