RSS Feed

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 – prints to the screen

a. echo $PATH – dumps the current path to STDOUT

b. echo $PWD – dumps ths contents of the $PWD variable

c. echo $OLDPWD – dumps the most recently visited directory

5. set – prints and optionally sets shell variables

6. clear – clears 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 desired directory

a. ‘cd ‘ with no options changes to the $HOME directory

b. ‘cd ~’ changes to the $HOME directory

c. ‘cd /’ changes 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 ../..’ changes us two-levels up in the directory tree

11. Arrow keys (up and down) navigates through your command history

12. BASH supports tab completion:

a. type unique characters in the command and press ‘Tab’ key

13. You can copy and paste in GNOME terminal windows using:

a. left button to block

b. right button to paste OR Ctrl-Shift-v to paste

14. ls – lists files and directories

a. ls / – lists the contents of the ‘/’ mount point

b. ls -l – lists the contents of a directory in long format:

Includes: permissions, links, ownership, size, date, name

c. ls -ld /etc – lists properties of the directory ‘/etc’, NOT the contents of ‘/etc’

d. ls -ltr – sorts 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. cat 123.txt 456.txt > 123456.txt – creates new catenated file

16. mkdir – creates a new directory

a. mkdir testRH5 – creates a ‘testRH5’ directory

17. cp – copies files

a. cp 123.txt testRH5/

By default, ‘cp’ does NOT preserve the original modification time

b. cp -v 456.txt testRH5/

18. mv – moves files

a. mv 123456.txt testRH5/ – 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 exist

b. touch 123456.txt – will update the timestamp

c. touch -t 200801091530 123456.txt – changes timestamp

21. stat – reveals statistics of files

a. stat 123456.txt – reveals full attributes of the file

22. find – finds files using search patterns

a. find / -name ‘fstab’

Note: ‘find’ can search for fields returned by the ‘stat’ command

23. alias – returns/sets aliases for commands

a. alias – dumps current aliases

b. alias copy=’cp -v’

Advertisements

About Ali abdo

Ali 32 years old from Egypt working as system engineer riding motorcycle to Support and develop Egyptian tourism, spread motorcycling.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: