Notes for Linux Skills Test PDF

Title Notes for Linux Skills Test
Author He DSD
Course Web Systems
Institution University of Technology Sydney
Pages 28
File Size 2.6 MB
File Type PDF
Total Downloads 74
Total Views 382

Summary

Skills Test NotesEd Questions:Lesson 1: 1)2)3)5)6)7)Lesson 3: 1)2)5)7)Lesson 5: 1)9)Lesson 6: 1)3)4)5)6)2)4)8)Lesson 2 - VIM:----------------------------------------------------------------------------------------------------------------Lesson 5 – Grep and Piping: GrepPiping...


Description

Skills Test Notes Ed Questions: Lesson 1: 1)

2)

3)

4)

5)

6)

7)

8)

Lesson 2: 4)

9)

Lesson 3: 1)

2)

3)

5)

7)

Lesson 5: 1)

2)

3)

4)

6)

7)

8)

9)

Lesson 6: 1)

2)

3)

4)

5)

6)

7)

8)

9)

Lesson 7: 1)

2)

3)

4)

5)

6)

7)

8)

9)

10)

Theory Behind the labs: Lesson 1 - Essentials:

----------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------

Lesson 2 - VIM:

----------------------------------------------------------------------------------------------------------------

Lesson 3 – Permissions:

Lesson 5 – Grep and Piping: Grep

Piping

Bash wildcards

Lesson 6 – Bash Scripting:

----------------------------------------------------------------------------------------------------------------

Lesson 7 – Data Processing:

----------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------

Grep Commands:

-q = Quiet mode -w= search for words -i = case insensitive -l = prints only the name from each file

ls Commands: -l = List the permissions of a file -S= sort alphabetically -A = almost all files except (. And ..) -r = reverse order of sort -s = file size

Tips:

You can use cat to remove the filename from a wc -w output.

If your searching for a file name containing a string or char ( *str will print files which end with the string ) ( str* will print files beginning with the string) and ( *str* will print all files with the string in the name)

CHMOD A combination of the letters ugoa controls which users' access to the file will be changed: the user who owns it (u), other users in the file's group (g), other users not in the file's group (o), or all users (a). If none of these are given, the effect is as if (a) were given, but bits that are set in the umask are not affected.

The operator + causes the selected file mode bits to be added to the existing file mode bits of each file; - causes

them to be removed; and = causes them to be added and causes unmentioned bits to be removed except that a direc‐ tory's unmentioned set user and group ID bits are not affected.

The letters rwxXst select file mode bits for the affected users: read (r), write (w), execute (or search for direc‐ tories) (x), execute/search only if the file is a directory or already has execute permission for some user (X), set user or group ID on execution (s), restricted deletion flag or sticky bit (t). Instead of one or more of these letters, you can specify exactly one of the letters ugo: the permissions granted to the user who owns the file (u), the permissions granted to other users who are members of the file's group (g), and the permissions granted to users that are in neither of the two preceding categories (o).

File descriptor 2 represents standard error. (other special file descriptors include 0 for standard input and 1 for standard output).

2> /dev/null means to redirect standard error to /dev/null. /dev/null is a special device that discards everything that is written to it.

STANDARD ERROR STANDRD OUTPUT

command 2>&1 - sends the STDERR to STDOUT

command 1>&2 - sends the STDOUT to STDERR

#!/bin/sh

GLOBBING

* Matches any string, including the null string.

? Matches any single character.

[] Matches a range of characters. A range looks like

any number of characters e.g. [1234567890] or [a-z] or [a-z,A-Z]

you can have a special "class" of characters e.g. [:blank:] - matches any whitespace, [:digit:] matches a numeric character, [:lower:] for any lowercase character, [:upper:] for uppercase, [:alpha:] for alphabetic character. Whats cool is that these classes will vary depending on the current character set - so European characters could get matched (e.g. é) You should enclose treat these "classes" as if they were a single character in the pattern. e.g. [[:upper:]a-z] would match 2 characters which start with an Uppercase letter.

{} Lets you group patterns seperated by commas. e.g. {*.doc,*.pdf} match all files ending with .doc or .pdf

[!] is a negative match e.g. [!a].doc represents all files EXCEPT a.doc

\ "escapes" the next character. So [\[\]] represents a pattern containing [ or ]

WORD COUNT

OPEN THE FILE THEN COUNT THE WORDS cat $1 (first argument) | wc -w

WHITE SPACE

Notice that the regular expression "\s\+" means "a sequence of one or more white spaces".

GREP

grep -w WHEN SEARCHING FOR A WORD (characters between delimiters). LEAVE BLANK IF SEARCHING FOR A STRING

Rather than matching only what you can type, meta-characters can also match properties of a string.

^, $ - carat and the dollar sign match the beginning and end of a line, respectively;

\ - the beginning and end of a word;

. - full-stop matches any character.

2.1 Listing files containing a particular string: -l (LOWERCASE L) In a directory containing a large number of files the names of files which contain strings matching a particular pattern can be listed using:

grep -l *

This can also be performed in a whole directory tree using the -r (recursive) option:

grep -lr *

USE '\|' to search for multiple strings grep "NAT\|MAT" /course/linuxgym/census/femalenames.txt^C

CUT cat cars.txt | cut -f1 -d, where -f1 indicates that field 1 is to be printed, and -d, indicates that the comma is the delimiter which separates the fields....


Similar Free PDFs