• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/195

Click to flip

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;

195 Cards in this Set

  • Front
  • Back
How to del a word before the point in cmd line?
ctrl-w
How to del a line the terminal before the point?
ctrl-u
How to paused/suspend a process/program?
ctrl-z
How to erase a character?
ctrl-h
How to report a snapshot of the current processes running?
$ ps
How to create a directory in a non-existing path?
mkdir -p
mm: mkdir -p(repare)
How do you ignore an alias?
Use 'backslash' or the 'command' commande before the cmd or yeat “ ” around it. For instance to ignore an alias called ls and run ls command enter
How to change word after point to all to lowercase letters?
ESC L
How to Change word after point to all capital letters.
ESC U
How to Kills the line after the point?
CTRL K
rm -rf folder/
remove all file and folders of a directory.
userdel -fr
Delete a user account and related files. option -f --force forces removal even if the user is logged. -r --remove remove files in the user's home directory and user mail spool(file with mail header).
How to convert a pdf to other format - like eg. png
convert -density 300 foo.pdf foo.png function from imagemagik suite.
How to enter editing mode of emacs or vi while in the shell ?
set -o emacs or set -o vi
How to check the background jobs ?
jobs
How to create a new 'tar' archive ?
tar cvf archive_name.tar dirname/
#It don't compress.
How to extract from a existing tar archive
tar xvf archive_name.tar
How to View an existing tar archive?
tar tvf archive_name.tar
How to search for a string in file?(case insensitive)
grep -i "the" demo_file
How to print the matched line, along with the 3 lines after it ?
Use grep with the option '-A'
grep -A 3 -i "example" demo_text
How to search for a given string in all files recursively?
#Use the option -r --recursive $ grep -r "ramesh" *
How to find files using file-name ( case in-sensitve find)?
# find . -iname "MyCProgram.c"
How to execute commands on files found by the find command?
$ find -iname "MyCProgram.c" -exec md5sum {} \;
# #Use the option '-exec' attention to the ending of the -exec {} \\;
How to find all empty files in home directory?
find ~ -empty
$ grep -vf file1 file2 > file3 # What is printed in file3 ?
The option '-v' makes the unmatched be printed in file3
How to login a remote host?
ssh -l jsmith remotehost.example.com
Convert a DOS file to UNIX file using sed.
$sed 's/.$//' filename
How to ignore white space while comparing files with diff ?
diff -w name_list.txt name_list_new.txt
How to sort in ascending order?
sort names.txt
How to sort in descending order?
sort -r names.txt
xargs
It takes a output of command and pass it as argument of another cmd.
$ find ~ -name '*.log' -print0 | xargs -0 rm -f
How to order files based on last modified?
$ ls -lt
# Last Modified Time - lt
How to create a .gz compressed file?
$ gzip test.txt
How to uncompress a *.gz file?
$ gzip -d test.txt.gz
How to display compression ratio of the compressed file using gzip?
$ gzip -l *.gz
compressed uncompressed ratio uncompressed_name
23709 97975 75.8% asp-patch-rpms.txt
How to create a *.bz2 compressed file?
$ bzip2 test.txt
How to uncompress a *.bz2 file?
bzip2 -d test.txt.bz2
How to extract a *.zip compressed file?
$ unzip test.zip
How to view the contents of *.zip file (Without unzipping it)?
$ unzip -l jasper.zip
Archive: jasper.zip
Length Date Time Name
-------- ---- ---- ----
40995 11-30-98 23:50 META-INF/MANIFEST.MF
32169 08-25-98 21:07 classes_
15964 08-25-98 21:07 classes_names
10542 08-25-98 21:07 classes_ncomp
What is and how is used the package manager of RedHat?
rpm -ivh MySQL-client-3.23.57-1.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]

-i : install a package
-v : verbose
-h : print hash marks as the package archive is unpacked.
How to change the mode of a script called hw?
chmod +x bin/hw
Sort passwd file by 3rd field.
$ sort -t: -k 3n /etc/passwd | more
-t is the field separator
-k column
n is compare numerical value.
How to 'cat' a file with line numbers?
##Use the -n option.
$ cat -n file-with-date
1 Tue Jan 23 17:25:44 CET 2003
How to print the output of sort in another file, without using ">"?
Use the option -o and the sorted file name before it. --output=FILE
write result to FILE instead of standard output
sort -o sorted-file file-tobe-sorted
How to create a compressed tar.gz file from a folder or file in Linux?
tar czf new-tar-file-name.tar.gz file-or-folder-to-archive

tar - the tar command.
c - create new archive.
z - compress the archive using gzip.
f - use archive file.
How to extract a compressed tar.gz file in Linux?
tar -xzf tar-file-name.tar.gz

Here is the command explanation:
tar - the tar command.
x - extract the archive.
z - uncompress the archive using gzip.
f - use archive file.
tar-file-name.tar.gz - the name of the tar.gz to create.
The tar command will extract all the files/folders in the archive to the current directory.
How to extract a compressed tar.bz2 file in Linux?
use the -j flag for the bzip2 format
tar -xjf tar-file-name.tar.gz

Here is the command explanation:
tar - the tar command.
x - extract the archive.
j - filter the archive through bzip2
f - use archive file.
tar-file-name.tar.gz - the name of the tar.gz to create.
How to shutdown the system and turn the power off immediately
shutdown -h now
How to shutdown the system after 10 minutes?
shutdown -h +10
How to Reboot the system using shutdown command?
shutdown -r now
How to Force the filesystem check during reboot?
shutdown -Fr now
How to connect to a remote server using ftp?
ftp IP/hostname
How to download multiple files, after conecting to ftp server?
ftp> mget *.html
What is the output of 'df' command ?
the current amount of free space on your disk drives
What is the output of the 'free' command ?
It displays the amount of free memory.
What 'virtual consoles' or 'virtual terminal' and how to access them ?
virtual terminals or virtual consoles, run 'behind' the desktop and can be accessed on most Linux distributions by pressing Ctrl-
Alt-F1 through Ctrl-Alt-F6
What the command 'cd - ' does ?
It jumps to the previous directory.
What to list hidden filenames ?
ls -a
How to determine a file type in linux ?
$ file test.pdf #command 'file'– Determine file type.
test.pdf: PDF document, version 1.4
What is the output of 'ls ~ /usr' ?
The list of filenames and directories of home directory and /usr directory.
What is the output of 'ls -ld ./directory/' ?
Shows the details of a directory rather than its contents.
What is the output of 'ls -F .' ?
This option will append an indicator character to the end of each listed name. For example, `
a “/” if the name is a directory.
What is the output of 'ls -r .' ?
Display the results in reverse order.
Normally, ls displays its results in ascending
alphabetical order
What is the output of 'ls -S .' ?
Sort results by file size.
What is the output of 'ls -t .' ?
Sort by modification time
What the 'less' command does ?
The less command is a program to view text files.
how can we copy all the HTML files from one directory to
another, but only copy files that do not exist in the destination directory or are newer than
the versions in the destination directory?
cp -u *.html destination_dir
How to make a match of one single character ?
Use "?". Example:
ls file?.txt # It will lists files with a one char after file.
How to Matches any character that is a member of the set characters?
[characters]
How to matches any character that is not a member of the set characters?
[!characters]
How to match any alphanumeric character?
[:alnum:]
How to match any digit in a expansion?
[:digit:]
How to match any lowercase letter ?
[:lower:]
How to match any uppercase letter ?
[:upper:]
What means cp -a -i -r -u or -v ?
-a, --archive, -i, --interactive, -r, --recursive, -u, --update; -v, --verbose.
What does it mean rm -i -r -f or -v ?
-i, --interactive, -r, --recursive, -f, --force; -v, --verbose.
What means mv -i, -u or -v ?
-i, --interactive, -u, --update; -v, --verbose.
How to check if a hard link and the file name refers to the same data ?
ls -i (--inode) shows the chain block number in the disk
How to determine the exact location of a given executable ?
command which. Ex, which ls. It dont work in buildin cmd of the bash
How to display a list of appropriate commands for a given keyword ?
apropos or man -k
How to display a command’s info entry ?
info command.name
How to display a very brief description of a command ?
whatis
How to see the contend of gziped file ?
zless command. Ex, zless foo.txt.gzip
How to make aliases ?
alias foo='cmd1; cmd2;...'
How to stop and alias ?
unalias command
How to see all the aliases defined in the environment ?
cmd alias with no other option or argument.
How to redirect standard error to a file ?
2> operator. Ex, ls -l /bin/usr 2> ls-error.txt
How to redirect both standard output and standard error at the same time to file ?
Bash old -v. ls /bin/usr > ls-output.txt 2>&1
#Bash new -v ls /bin/usr &> ls-output.txt
Where is the classical place in Unix system to diposed unwanted output ?
Redirect to /dev/null
How to watch the progress of log files as they are being written ?
tail -f filename # tail --follow
What the tee command does ?
It is T in pipeline. Ex, ls /usr/bin | tee ls.txt | grep zip
How to sync two directories in a local computer?
rsync -zvr source destination
-z is to enable compression
-v verbose
-r indicates recursive
Why to use rsync with the option -a ?
indicates archive mode. -a option does the following: Recursive mode, Preserves symbolic links, Preserves permissions.
Preserves timestamp
Preserves owner and group
How to synchronize Files From Local to Remote?
rsync allows to synchronize files/dir between the local and remote system. Ex; $ rsync -avz /root/temp/ username@machinename:path
How to join to files according to a common field?
$ join -1 2 -2 2 A.txt B.txt # -1 first file, -2 second file, the number next to the flags points to the field, in this case the 2nd.
How to choose the delimiter in join cmd?
$ join -t, -1 3 -2 1 A.txt B.txt
1,John,A,A
2,Linda,B,B
3,Rares,C,C
How to convert a file with multiple spaces between the fields to a single spaced file?
sed -i 's/\s\+/ /g' A.txt
How to join files ignoring case of the letters?
$ join -i -1 2 -2 2 A.txt B.txt
How to join choosing the format of the output?
$ join -o 1.1 2.1 -1 2 -2 2 A.txt B.txt
# 1.1 and 2.1 refers to file.field
John 1
Linda 2
Rares 3
How to print not matched lines with join cmd?
$ join -a 1 -o 1.1 2.1 -1 2 -2 2 A.txt B.txt
# -a prints not matched line from the first file.
$ join -a 1 -a 2 -o 1.1 2.1 -1 2 -2 2 A.txt B.txt
# Or we can print non-matched lines from boths files.
If apropos it's not on your system, how to create it ?
By adding the following line to your .bashrc file: alias apropos = 'man -k \!'
How to see 'who you are' in a unix system?
whoami or who am i cmd
How to lists the account names of all people using the system?
% users
How to to find out who is logged on to the system, what line they’re on, and how long they’ve been logged in?
who
How to find out what everyone else is doing in the system ?
w
What is the infix calculator of unix ?
bc
How to access the higher math functions in bc ?
bc -l math
How to find you identities in the system ?
id
How to view the variables of the environment ?
env # many unix systems offer printenv instead of env.
How to list files with ls as a comma-separated list?
ls -m
How to show size of files, in blocks (typically, 1 block = 1,024 bytes)?
ls -s
How to force multiple-column output on listings?
ls -C
How to force single-column output on listings?
ls -1
How many bytes has in one kilobyte ?
A kilobyte is 1,024 bytes.
How many bytes has in one block in unix ?
It is 1 kilobyte or 512 bytes.
How to sort the output of ls in first-row order ?
ls -x
How to list the directory tree recursively in ls ?
ls -R
How to update times of files in ls -l ?
touch
How to check disk-space usage in unix ?
du command lists the size, in kilobytes, of all directories at or below the current point in the file system.
How to get the total disk-space in usage in a directory ?
du -s or du -c
How to ge the total disk-space usage of all files ?
du -a
how to check much disk space is available on the overall in UNIX system ?
df
How to skip numbering blank lines in when using cat ?
cat -b filename
How to sort ignoring leading blanks?
sort -b file.name
How to sort in dictionary order(only letters,digits and blanks are significant)?
sort -d filename
How to sort ignoring case of the words (fold uppercase into lowercase)?
sort -f file.name
How to remove duplicated lines of a file?
uniq -c file.name
What is the regexp character for beginning of the line?
^ # Ex, grep '^taylor' /etc/passwd
What is the regexp character that matches any one character, except a newline?
. # 13 + at least one of any character (including a space)
How to match any single character in a specified set?
[xyz]
How to match any single character not in a specified set?
[^xyz]
How to match zero or more occurences fo character c?
c*
What is the regexp character for to search in the end of a line?
$
What is the regexp character look for many patterns at once?
c+
How to grep the total number of matched lines?
grep -c file.name
How to grep a list with the names of the files that contain the specified pattern?
grep -l 'pattern' file.name
How to grep including line number?
grep -n 'pattern' file.name
How to chance all letters to uppercase with tr?
cat /etc/passwd | tr '[a-z]' '[A-Z]'
How to use tr for rotation fencription of words (ROT13)?
cat file.name | tr '[a-zA-Z]' '[n-za-mN-ZA-M]'
How to reverse ROT13 ?
cat file.name | tr '[n-za-mN-ZA-M]' '[a-zA-Z]'
What is the cmd for to choose a new shell?
chsh
Where to see the list of shells of the system ?
/etc/shells
Where to edit the $PATH ?
.profile or .bash_profile
How to grep the precisce word, a whole word ?
grep -w '172.17.4.1' tmp
How to make integer calculation in bash prompt?
echo $[ 44 * 250]
How to add number lines of a file?
nl file.name.txt
How to 'redirect' a series of commands to a variable?
Put the commands inside parentesis. PHENO=$(echo "$i" | cut -c 17- | tr '_table.txt' ' ')
How to list files with color?
ls -G
What is the is the types of file atributes in ls -l ?
directory (d), a normal file (-), a block-oriented device (b), a character-oriented device (c) or a link (l)
How to deny the permission of file to write for the group read for others, but allow execute for all?
chmod g-w, o-r, a+x
What the letters "ASacdijsu" means in the new file attribute in the Linux second extende file system?
do not update time stamp (A), synchronous updates (S), append only (a), compressed (c), no dump (d), immutable (i), data journaling (j), secure deletion (s), and undeletable (u)
How to extract a tar.gz file in a different directory than working directory
tar xzvf tmp.tar.gz -C sandbox/
How to use logical operators AND/OR with find?
AND is by defauld, and OR is -o
How to define file or directory using find?
find direc -type f -name "file.name" or find direc -type d -name "directory.name"
How to define the name of the file or directory using find?
find direc -type f -name "file.name" or find direc -type d -name "directory.name"
How to search (find cmd) Search for files larger (+) or smaller(-) than a number of 512-byte blocks?
use -size find direc -type f -name "file.name" -size +6
How to Search (with find) for files that were last changed x days ago?
-ctime
How to Execute a command on all found files. The syntax?
-exec command {} \; #Example find dirc -type -f -size -6 -name "*[0-9]" -exec cp {} find-found \;
Give an example of the use of find as backup tool?
find *.seq -exec cp {} Backup/{}.backup \;
How to remove blank lines with sed?
sed '/^$/d' asd1
What are the most common format specifiers of printf?
%s, %d, %f, %b and %x, string, integers, float, binary(expand escape sequences ), and prints integers into hexadecimals.
What is the difference between %s and %b?
%b expand escape sequences.
How to print scientific notation with printf?
%e
How print numbers preceded by zeros?
printf "%04d\n" 12 23 34
How specify the precision of a floating-point number in printf?
printf "%.2f\n" 4.579 #width specifier with a decimal fraction.
How specify the maximum widht of a string in printf?
printf "%12.4s\n" John Jackson Walter
How to print into a variable with printf?
printf -v num4 "%04d" 4
How the I/O (input/output) streams are referred by the system?
file descriptors (FDs). These are 0, 1, and 2, respectively. The stream names are also often contracted to stdin, stdout, and stderr.
How to send stderr to a file?
redirect 2> ERRORFILE
How to redirected stderr to another I/O stream?
Using >&N where N is the number of the file descriptor. Ex, printf '%s\n%v\n' OK? Oops! > FILE 2>&1
How to send both stdout and stderr to same file?
printf '%s\n%v\n' OK? Oops! &> FILE
How to add number lines of a file?
nl file.name.txt
How to delete a string with tr?
tr -d ',' < list.txt
How to make a list of all words of a text?
tr -cs "[:alpha:]" < file.name.txt # -c : Complement the set of characters in string1 -s : Replace each input sequence of a repeated character that is listed in SET1 with a single occurrence of that character+
how to remove all non-printable characters from myfile.txt?
tr -cd "[:print:]" < myfile.txt
How to remove blank lines with grep?
grep -v '^$' input
How to use 'or' logical operator with grep command without any option?
grep 'pattern1\|pattern2' filename
What is the option for grep with logical 'or'?
grep -E 'pattern1|pattern2' filename
egrep 'pattern1|pattern2' filename
How to use the logical operator 'and' with grep command ?
grep -E 'pattern1.*pattern2' filename # Don't exist and in grep, it is simulated, remember pipe greps simulates AND.
How to use the logical operators 'and' and 'or' with grep command ?
grep -E 'pattern1.*pattern2|pattern2.*pattern1' filename
How to grep with 'and' logical operator in any order of the patterns?
grep -E 'Manager.*Sales|Sales.*Manager' employee.txt
How to simulate logical 'not' with grep?
grep -v 'pattern' filename
How to print \t in mac os X in bash?
ctrl+v+tab
How to see which is the default shell of the system?
echo $0
What means 'exit status 0'?
No error occurred in the execution of cmd, program.
How to execute commands with 'AND'?
cmd1 && cmd2 ## second cmd is executed only if the first has exit status 0.
How to execute commands with 'OR'?
cmd1 || cmd2 ## second cmd is executed only if the first has non-zero exit status.
What are 'daemons'?
Background system programs running at the start of the system.
What the crontab cmd does?
The crontab command creates a crontab file containing commands and instructions for the cron daemon to execute.
How to edit the crontab file?
crontab -e #If not existent, creates the crontab file.
How to display your crontab file?
crontab -l
How to remove the crontab file?
crontab -r
How many entries exits in crontab file?
6 entries. minute, hour, day, month, weekday, commands.
What is the use of '\<pattern\>' in grep?
It matches the exact word.
What is the regex for blank lines?
^$