Popular Posts

7/25/2012

Basic Linux Shell Script Part 1


Hello Guy Today I'll show you some Basic Linux shelll script.
Open and test the below script :

#### Introduction to Shell Script ..!
======================================= By Mr. Dara ....
### Basic Linux Commands ####

1. tty - reveals the current terminal
2. whoami - reveals the currently logged-in user
3. which - reveals where in the search path a program is located
4. echo - print to the screen
a. echo $PATH - dumps the current path to STDOUT
5. set - prints and optionally sets shell variables
6. clear - clear the screen or terminal
7. reset - resets the screen buffer
8. history - reveals your command history
a. !690 - executes the 690th command in our history
b. command history is maintained on a per-user basis via:
~/.bash_history
~ = users's $HOME directory in the BASH shell
9. pwd - prints the working directory
10. cd - changes directory to the desired directory
a. 'cd ' with no options changs to the $HOME directory 'Destop'
b. 'cd ~' change to $HOME directory
c. 'cd /' change to the root of the file system
d. 'cd Desktop/' changes us to the relative directory 'Desktop'
e. 'cd ..' changes us one-level up in the directory tree
f. 'cd ../..' chage us two-level up in the direcoty tree
11. Arrow Keys (up and down) navigates through your command history
12. BASH Supports tap completion:
a. type unique charaters in the command and press 'Tab' key
13. You can copy and paste in GNOME terminal and window using :
a. left button to block
b. right button to paste OR Ctrl-Shift-v to paste

14. ls - list files and directories
a. ls / - list the contents of the '/' mount point
b. ls -l - list the contents of a directory in long format :
Include: permissions, links, ownership, size, date, name
c. ls -ld /etc - list the properties of the directory '/etc', NOT the contents of '/etc'
d. ls -ltr - sort chronologically from older to newer (bottom)
e. ls --help - returns possible usage information
f. ls -a - reveals hidden files. e.g.. 'bash_history'
Note: files/directories prefixed with '.' are hidden. e.g. '.bash_history'

15. cat - catenates files
a. cat 123.txt - dumps the contents of '123.txt' to STDOUT
b. cat 123.txt 456.txt dumps both files to STDOUT
c. cat123.txt 456.txt > 123456.txt - create new catenated file

16. mkdir - creates a new directory
a. mkdir dara - creates a 'dara' directory

17. cp - copies files
a. cp 123.txt dara/
by default, 'cp' does NOT preserve the original modification time
b. cp -v 456.txt dara/

18. mv - moves files
a. mv 123456.txt dara/ - moves the file, preserving timestamp

19. rm - removes files/directories
a. rm 123.txt
b. rm -rf 456.txt - removes recursively and enforces

20. touch - creates blank file/updates timestamp
a. touch test.txt - will create a zero-byte file, if it doesn't exit
b. touch 123456.txt - will update the timestamp
c. touch -t 201201011530 123456.txt - change timestamp
21. stat - reveals statistics of tiles
a. stat 123456.txt - reveals full attributes of the file

22. find - finds files using search patterns
a. find / -name 'fstap'
Note : 'find' can search for fields returned by the 'stat' command
23. alias - returns/sets a liases for commands
a. alias - dumps current aliases
b. alias copy='cp -v'



#### Thanks for first step ..## wait to see the next Lesson ..


0 comments:

Post a Comment