GNU/Linux bilješke 1 - dio


 

S obzirom da sam već uveliko uključen u svoj aktuelni Udemy Linux kurs, po imenu 'The Complete Linux LPIC-1 Certification Course Exams 101-102, prenosim u ovom svom članku prvi dio bilješki sa konkretnim primjerima. Kurs je zaista masivan a prvi dio bilješki uglavnom pokriva osnovne Linux komande i njihovu upotrebu. Ove bilješke će biti prenesene na Engleskom jeziku jer je sam kurs tako koncipiran. 


1. There are several shell in Linux such as bash, bsh, csh, ksh, zsh; most common one in use is the BASH (Bourne Again Shell) or bash.


2. The pwd command stands for present working directory. Once typed in bash prompt, it will display your current working directory. 


3. Second most important command is the ls command. This command is used for listing the content of directory. Once used with -l option, it will list the content in detail with files permissions. The (-) dash sign designates the file, where (d) sign designates the directory. Once listed, you will see bunch of characters such as -rwx-. These are file permissions which tell you, who can read, write and execute the file. 


4. You can list the content of directory with the following sample: 

# ls -l data - list the content of directory data with files permissions

# ls data - list the content od data directory without options


5. In order to navigate trough directories, we use cd command. Once we type cd .. we can jump straight to the parent directory. 

# cd /amar/data - enter data directory in /amar directory

# cd .. - return from data directory in /amar directory


6. Previously typed commands can be shown by pressing up and down arrow key. To see all the commands previously typed, we can use history command. The history command can store up to 1000 entries. To clear the history file, we can use 

# history -c 


7. To see the size or maximum number of lines that history file can store, we can use the following command: 

# echo $HISTSIZE | HISTSIZE is environment variable


8. All the commands typed in bash prompt resides inside user /home directory and that file is known as .bash_history.


9. In order to type multiple commands on a bash prompt, we can use semicolon (;) sign. The following command will create a directory test and rename it into test1. 

# mkdir test; mv test test1


10. Second way is using the && signs. It works the way that it waits for the first command to be executed successfully and than it moves on to next command, only if the first one is executed. Here's the quick sample. 

# cp doc1.txt /home/amar/doc && mkdir doc

This command will fail due to fact that there is no doc.1.txt file, second there is no doc directory within the /home and therefore the command will display a quick note: 'cp: cannot stat 'doc1.txt': No such file or directory'. 


11. In order to create a file, we can use the touch command. Besides creating a new file, this command is also used to change the time stamp of the files. To make a file, we can use the following command.

# touch test1.txt 


12. In order to copy the file from one location to another, we use cp command. The following command will copy foo file into bar file, automatically creating a new file.

# cp foo bar 


13. To copy a complete directory with it's files or sub-directories, we can use the following command.

# cp -R /home/Desktop/data   /home/amar/kopije

The above command use -R switch which tells the command, copy all the files and directories inside 'data' into directory by the name 'kopije'.


14. In order to remove the file or directory, we use rm command. Here's the sample.

# rm -rf data

Note: In this sample rm command uses -rf switch. The r character is for remove while the f character orders the rm command to forcefully remove all the content within this directory including files and sub-directories, if any. 

 
15. In order to make a new directory, we use the mkdir command. Here's a quick sample.

# mkdir data 


16. In order to write to a file, we use the echo, built in bash command. Here's a quick sample.

# echo 'This is a test1 file' > test1.txt 


17. In order to read the content of a file, we use the cat command. Here's a quick sample.

# cat test1.txt 

Once typed, we will get the following display output saying: ' This is a test file'. 


18. In order to display the size of directory, we use du command. Here's a quick sample.

# du -h data 

Note: The -h option is to display the size of the directory in human readable mode, or instead of numbers, there will be KB, MB, GB type of size. 


19. In order to list only directories inside desired location, we use the following command.

# ls -d */  

This command will display all the directories ending on back slash sign /. 


20. In case there are inside the directory files beginning on b character and ending on k character, and you would like to list them, the following command is going to be used.


# ls b??k 

Note: The ?? signs in above command are simply telling the ls command that I did not specify the characters in between. 


Ovo bi bio prvi dio mojih bilješki, aktuelnog Udemy Linux kursa kojeg već odavno pratim. Svakako ostavite sugestije, kritike, prijedloge, a ako nešto od ovoga naučite, bit će mi drago. Do čitanja. 

Share:

Nema komentara:

Objavi komentar

Zajednica

POPULARNI POSTOVI

Oznake

NAJNOVIJE