0% found this document useful (0 votes)
54 views

Files:: Ls Ls - L Ls - A Esc K More Filename

The document provides descriptions of common Linux commands and utilities for working with files, directories, text editing and processing. It explains commands for listing, moving, copying, deleting and compressing files, as well as commands for viewing file contents and comparing differences between files. Additionally, it outlines commands and functions for the vi text editor, searching for patterns in files, manipulating the terminal, and process monitoring utilities.

Uploaded by

Tulasi Konduru
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Files:: Ls Ls - L Ls - A Esc K More Filename

The document provides descriptions of common Linux commands and utilities for working with files, directories, text editing and processing. It explains commands for listing, moving, copying, deleting and compressing files, as well as commands for viewing file contents and comparing differences between files. Additionally, it outlines commands and functions for the vi text editor, searching for patterns in files, manipulating the terminal, and process monitoring utilities.

Uploaded by

Tulasi Konduru
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

Files:

ls ls -l ls -a Esc k more filename lists your files lists your files in 'long format', lists all files, including the hidden files Prev commands shows the first part of a file, just as much as will fit on one screen. Just hit the space bar to see more or q to quit. You can use /pattern to search for a pattern. Renames a file or moves it into a different directory Copies a file copy one directory into another Removes a file. Ask you for confirmation before actually deleting anything. Compares files line by line. Diff command point to which lines need be: Added (a) Deleted (d) Changed (c) cmp file1 file2 wc filename chmod grep string filename tail filename ff cut Compares file byte by byte Tells you how many lines, words, and characters there are in a file Lets you change the read, write, and execute permissions on your files. search for a string in a file show the last few lines of a file find files anywhere on the system. If you use ff -p you don't even need the full name, just the beginning. Bytes (-b), characters (-c), or fields (-f) separated by a delimiter (-d the tab character by default). Example: cut -c 4-10 file : Outputs characters fro 4 to 10 in each line from the file

mv filename1 filename2 cp filename1 filename2 cp R src-dir dest-dir rm filename rm -i filename diff filename1 filename2

Split

Split l/-b Filename Outputfile -l linenumber, -b bytes If output filename is not given, the default filename of x is used, for example, xaa, xab, etc.

Cat

Joining files Example: cat xaa xbb>Filename

date Find

date "+%m/%d/%y" find . -name "sls_data*" -print grep -i sls_data_src_dim *

File Compression:
gzip filename gunzip filename gzcat filename compresses files, so that they take up much less space. uncompresses files compressed by gzip. lets you look at a gzipped file without actually having to gunzip it (same as gunzip -c). You can even print it directly, using gzcat filename | lpr Shows disk space available on the system Shows how much disk space is being used up by folders

df du

Directories:
mkdir dirname cd dirname pwd make a new directory Change directory Present working directory

Redirection:
grep string filename > Redirects the output to a file 'newfile'.

newfile

filename >> existfile pwd

Appends the output of the grep command to the end of the existfile Present working directory

PS command:
a -A -c -d -e -f -j -l -L -P -y List information about all processes most frequently requested List information for all processes. Identical to -e, below. Print information in a format that reflects scheduler properties as described in priocntl. List information about all processes except session leaders. List information about every process now running. Generate a full listing. Print session ID and process group ID. Generate a long listing. Print information about each light weight process (lwp) in each selected process. Print the number of the processor to which the process or lwp is bound, if any, under an additional column header, PSR. Under a long listing (-l), omit the obsolete F and ADDR columns and include an RSS column to report the resident set size of the process. Under the -y option, both RSS and SZ will be reported in units of kilobytes instead of pages. List only process data whose group leader's ID number(s) appears in grplist. (A group leader is a process whose process ID number is identical to its process group ID number.) Specify the name of an alternative system namelist file in place of the default. This option is accepted for compatibility, but is ignored. Print information according to the format specification given in format. This is fully described in DISPLAY FORMATS. Multiple -o options can be specified; the format specification will be

-g grplist

-n namelist

-o format

interpreted as the space-character-separated concatenation of all the format option-arguments. -p proclist -s sidlist -t term List only process data whose process ID numbers are given in proclist. List information on all session leaders whose IDs appear in sidlist. List only process data associated with term. Terminal identifiers are specified as a device file name, and an identifier. For example, term/a, or pts/0. List only process data whose effective user ID number or login name is given in uidlist. In the listing, the numerical user ID will be printed unless you give the -f option, which prints the login name. List information for processes whose real user ID numbers or login names are given in uidlist. The uidlist must be a single argument in the form of a blank- or comma-separated list. List information for processes whose real group ID numbers are given in gidlist. The gidlist must be a single argument in the form of a blank- or comma-separated list.

-u uidlist

-U uidlist

-G gidlist

Patterns in files:
fgrep searches files for one or more pattern arguments, but does not use regular expressions. It does direct string comparison to find matching lines of text in the input. works similarly, but uses extended regular expression matching. If you include special characters in patterns typed on the command line, escape them by enclosing them in apostrophes to prevent inadvertent misinterpretation by the shell or command interpreter. To match a character that is special to egrep, a backslash (\) should be put in front of the character. It is usually easier to use fgrep if you don't need special pattern matching. if you search more than one file at a time, the results contain the name of the file from which the string was found. This option turns off that feature, giving you only the lines without the file name.

egrep

-h

-w -b -c -E -e

restricts the search to whole words only precedes each matched line with its file block number. displays only a count of the number of matched lines and not the lines themselves. causes grep to behave like egrep. pattern specifies one or more patterns for which grep is to search. You may indicate each pattern with a separate -e option character, or with newlines within pattern. For example, the following two commands are equivalent: grep -e pattern_one -e pattern_two file grep -e 'pattern_one pattern_two' file

-F -f -i -l -n -q -s -U[b|B|l|L]

causes grep to behave like fgrep. patternfile reads one or more patterns from patternfile. Patterns in patternfile are separated by newlines. tells grep to ignore case so that it treats "the" and "The" as the same word lists only the file names that contain the matching lines. precedes each line with the line number where it was found suppresses output and simply returns appropriate return code. suppresses the display of any error messages for nonexistent or unreadable files. forces the specified files to be treated as Unicode files. By default, these utilities assume that Unicode characters are little-endian. If a byte-order marker is present, that is used to determine the byte order for the characters. You can force Unicode characters to be treated as big-endian by specifying -Ub or -UB. Similarly, you can force them to be treated as little-endian by specifying -Ul or -UL. displays all lines not matching a pattern. requires a string to match an entire line. Displays terminal length and width. Changes the width and height of the terminal.

-v -x stty -a stty rows <n>cols <n>

VI:
:set number :set nonumber :e filename Turns on line numbering Turns off line numbering Open the file 'filename' for editing.

Quitting
:w :wq! :q :q! :x ZZ Write the current file Write the file and quit Exit as long as there have been no changes Quit with no changes Exit, saving changes Exit and save changes if any have been made

Inserting Text
i Insert before cursor

I a A o O r

Insert before line Append after cursor Append after line Open a new line after current line Open a new line before current line Replace one character

Motion
h j k l w W Move left Move down Move up Move right Move to next word Move to next blank delimited word

b B e E ( ) { } 0 $ 1G G nG :n fc Fc H M L %

Move to the beginning of the word Move to the beginning of blank delimted word Move to the end of the word Move to the end of Blank delimited word Move a sentence back Move a sentence forward Move a paragraph back Move a paragraph forward Move to the begining of the line Move to the end of the line Move to the first line of the file Move to the last line of the file Move to nth line of the file Move to nth line of the file Move forward to c Move back to c Move to top of screen Move to middle of screen Move to botton of screen Move to associated ( ), { }, [ ]

Deleting Text
x X D dd :d dw Delete character to the right of cursor Delete character to the left of cursor Delete to the end of the line Delete current line Delete current line Deletes a word

Changing text

cw C cc

Changes a word Change to the end of the line Change the whole line

Putting text
p P Put after the position or after the line Put before the poition or before the line

Search for strings


/string ?string n N Search forward for string Search back for string Search for next instance of string Search for previous instance of string

Replace
:%s/pattern/string/flags :%s/(ctrl-v)(ctrl-m)//g g c & Replace pattern with string according to flags. Remove trailing spaces after FTP from windows (^M) Flag - Replace all occurences of pattern Flag - Confirm replaces. Repeat last :s command

Files
:w file :r file :n :p :e file !!program Write to file Read file in after line Go to next file Go to previos file Edit file Replace line with output from program

Other
~ Toggle upp and lower case

J . u U

Join lines Repeat last text-changing command Undo last change Undo all changes to line

Ranges
:n,m :. :$ :'c :% :g/pattern/ Range - Lines n-m Range - Current line Range - Last line Range - Marker c Range - All lines in file Range - All lines that contain pattern

Semaphores, A semaphore is nothing but a term used in UNIX for a variable which acts as a counter. Basically, the semaphore is a variable that keeps track of all the processes that currently want to access the shared resource and it makes sure only one process at a time actually accesses it. ipcs s :will give the list of existing semaphores.

You might also like