• 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/42

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;

42 Cards in this Set

  • Front
  • Back

Searching for text inside a file

grep pattern file



To invert the match: grep -v pattern file

grep options

-i search ignoring case


-c number of occurrences


-n precede output with line numbers

List directories no contents

ls -ld


ls -d

Go to the previous directory

cd -


cd $OLDPWD

Symbols for users

$ normal user


# super user

Symlink

Symbolic link



Points to the location of the actual file or directory

What user you are working as

whoami

Command to change permissions (modes)

chmod - change mode


ugoa - the user category: user(owner) group others all


+ - = - add substract or set premissions


r w x - read write execute



$chmod g+w sales.data


$chmod g-w sales.data


Run the last command as root

sudo !!


su -c "!!"

Sort by time in reserve other

ls -latr

Comments

#



Octofhorpe


Hash


Square


Pound sign


Number sign

Listing files with color

ls -F


ls --color


Reuse the last word (last argument) from the previous command

!$



$unzip tspreport.zip


$rm !$

Reuse the nth word from a previous command

$!!:N



$avconv -i screencast.mp4 podcast.mp3


$mv !!:2 converted/

Reuse the second word (first argument) from the previous command

!^


Event designator

!u most recent that starts with u



References a command in your shell history.

Line continuation character

\

Sudo

Superuse do

Viewing files in real time

tail -f file

Find files by index

To know where a file resides.



locate pattern



$locate tpsrep



Query the index or.database created by updatedb and not looking at each file. Index is not in real time.


Cut file

cut out selected portions of file. If a file is omitted, use standard input.



cut -d delimiter : Use delimiter as a file separator.



cut -f N : Display the nth field



$strings bluetraim.mp3 | grep -i john | head -1 |cut -d ' ' - f 2

man command

help: type h while viewing a manual page.



Enter: move down one line.



Space: move down one page



g: move to the top of the page



G: move to the bottom of the page.



q: quit

Environment variable

Storage location that has a name an a value. Ex: PATH

Search pattern to delete multiple files at once

ls s* check


rm s*


ls -d .*


rm .*


Null device

/dev/null To ignore output. Special file that throws away whatever is fed to it. (bit bucket). If.you do not want to see errors on your screen and you do not want to save them to a file, you can redirected them to /dev/null $ls here not-here 2> /dev/null here

groups

To see what.groups you are a member of.



If you supply another users id as an argument you will see.the list of groups to which that user belongs.



$groups


$id -Gn


$groups moniccon

read, write and execute numbers modes

0 ---


1 --x


2 -w-


3 -wx


4 r--


5 r-x


6 rw-


7 rwx



chmod 754 file

ls first character

- regular file


d directory


l symbolic link

Permissions

r read


w write


x execute (when d it allows access to contents and metadata for entries in the directory)


Category of users

u user


g group


o other


a all



Every user is member of at least one group called their primary group.

Transferring and copying files

scp secure copy


Sftp ssh file transfer protocol (filezilla)



$scp source dest


$sftp username@host : connect to host as username to begin a secure transfer session.

Outputs redirections

> to redirect output


< to redirect input



>> redirects standard output to a file and appends to any existing contents. If no file exists it creates one.



$ls -lF /opt/apache > files.txt


$sort < files.txt


$sort < files.txt > sortedfiles.txt


$ls here not-here 1> out 2> out.err

PATH

Environment variable that contains a lost of directories that contain executable commands

export | grep $SHELL

Shows the shell that you are using

ssh tunnel

ssh -i key_location -p port_number user-name@server

su [username]

Change user id or become superuser.



Options:


- provide an environment similar to what the user would expect had the usser logged in directly.


-c command: specify a command to be executed.



If the command is more than one word in length, it needs to be quoted.

yum

yum remove package : remove/uninstall package



yum info [package] -display : information about a package



ls

ls: list directory contents.



cd [dir]: changes the current directory to dir. Without a dir.it navigates to home directory.



pwd: displays the present working directory name.



cat [file] : concatenates and displays files to view contents of a file

Directories symbols

. This directory


.. The parent directory


/ directory separator. Directories end in a forward slash and this is often assumed.

| pipes

Means take the standard output from the preceding command and pass it as the standard input to the following command.



$strings bluetrain.mp3 | grep -i john



If the first command displays error messages those will not be passed to the second command. Those error messages are called "standard error" output.



$string bluetrain.mp3 | grep -i john |head -l

| pipes

$grep bob /etc/password |less


$ls -l /usr/bin/ | less


$ps -ef | more

$EDITOR

Environment variable that has which program to use for editing.



crontab -e



invokes the editor specified by the $EDITOR environment variable.