Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linux 201 Training Module Linux Adv File Mgmt.

Similar presentations


Presentation on theme: "Linux 201 Training Module Linux Adv File Mgmt."— Presentation transcript:

1 Linux 201 Training Module Linux Adv File Mgmt

2 This presentation will cover the following topics
PATH Concept ln which cut sort, uniq diff find grep options Redirection >, | , tee chown, chgrp

3 PATH PATH is an environmental variable in Linux that tells the shell which directories search for executable files in response to commands issued by a user. $] echo $PATH /opt/apache-maven /bin:/home/netstorm/work/bin:/home/n etstorm/work/tools:/bin:/apps/java/jdk1.6.0_ 24/bin:/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr /local/bin:/opt/cavisson/monitors/bin:/usr/lib 64/qt- 3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local /sbin:

4 ln command To make a symbolic link : ln /original/file /new/link
This makes /original/file and /new/link the same file - edit one and the other will change. The file will not be gone until both /original/file and /new/link are deleted. To make a soft symbolic link : ln -s /original/file /new/link

5 which command Locate a command shows the full path of commands.
$ which cat /bin/cat

6 cut command Cut out selected fields of each line of a file.
name=`who am i | cut -f1 -d' '` Set name to current login name.

7 sort command sort lines of text files Sort a file in ascending order
$ sort names.txt Sort a file in descending order $ sort -r names.txt

8 Uniq comand remove duplicate lines from a sorted file
sort myfile | uniq eliminates duplicate lines from the stream (the symbol "|" pipes the output from sort myfile to the uniq command).

9 diff command diff - find differences between two files
$]diff from-file to-file

10 find command find - search for files in a directory hierarchy
find / -name game Looks for a file named "game" starting at the root directory  find /usr -name *stat Find every file under the directory /usr ending in "stat".

11 Grep Options Search for a string in a file grep "Error" logfile.txt
Case insensitive search grep -i "UNix" file.txt Specifying the search string as a regular expression pattern. grep "^[0-9].*" file.txt This will search for the lines which starts with a number.

12 Checking for the whole words in a file.
grep -w "world" file.txt The -w option to grep makes it match only the whole words. Searching for a sting in all files recursively grep -r "string" * Displaying the count of number of matches. grep -c "sting" file.txt

13 redirection By default, standard output directs its contents to the display. To redirect standard output to a file, the ">" character is used like this: me]$ ls > file_list.txt

14 Pipes With pipes, the standard output of one command is fed into the standard input of another. E.g me]$ ls -l | less

15 Tee command Read from an input and write to a standard output and file. ls *.txt | wc -l | tee /dev/tty count.txt In the above example the ls command would list all .txt files in the current directory, take a word count (wc) by the amount of lines (-l) and the output displayed to the /dev/tty (terminal) will be sent to the count.txt.

16 chown & chgrp command To change the owner of a file/directory, use the chown command $ chown newowner file/dir To change the group of a file/directory, use the chgrp command. $ chgrp newgroup file/dir Both chown and chgrp support the -r option for recursively changing the owner or group of an entire subdirectory


Download ppt "Linux 201 Training Module Linux Adv File Mgmt."

Similar presentations


Ads by Google