Adds basic_cmd command informations

This commit is contained in:
vl4dd 2021-04-07 10:18:32 -04:00
parent 88a89c284c
commit 14fb1525fb
1 changed files with 100 additions and 1 deletions

View File

@ -84,6 +84,13 @@ back to previous folder
> rm -rf filename
Delete all of the files in the diectory including all subdirectories and tier contents
> $ rm -r \* .\*
Remove all files with the .doc extension recursively in the current working directory.
> $ rm \*\*/\*.doc
- Mv: Move directory (can be used to rename a file)
> mv file /opt/movedfile
@ -185,7 +192,52 @@ total 4
> -rw-r--**rw**- 1 marie marie 12 Apr 7 05:44 test
Number alternatives:
##Using chmod in absolute mode
In the absolute mode, permissions are represented in numeric form (octal system to be precise). In this system, each file permission is represented by a number.
- r (read) = 4
- w (write) = 2
- x (execute) = 1
- (no permission) = 0
With these numeric values, you can combine them and thus one number can be used to represent the entire permission set.
| Number | Permission |
|--------|------------|
| 0 | — |
| 1 | x |
| 2 | -w- |
| 3 (i.e. 2+1) | -wx |
| 4 | r |
| 5 (i.e. 4+1) | r-x |
| 6 (i.e. 4+2) | rw- |
| 7 (i.e. 4+2+1) | rwx |
most commonly used:
755 644 600 640
Can you guess the file permission in numbers on agatha.txt file in our example so far? Thats right, its 764.
Now that you know what number represents which permission, lets see how to change file permission using this knowledge.
Suppose you want to change the file permission on agatha.txt so that everyone can read and write but no one can execute it? In that case, you can use the chmod command like this:
> $ chmod 666 agatha.txt
## Danger : if a folder has not the X (executable) right => you cannot open it.
-R for recursive on folder
If you list agatha.txt now, youll see that the permission has been changed.
> -rw-rw-rw- 1 abhishek abhishek 457 Aug 10 11:55 agatha.txt
- Chown: change file owner and group
> $ sudo chown marie:marie agatha.txt
> -rw-rw-rw- 1 marie marie 457 Aug 10 11:56 agatha.txt
### Groups
Groups: print the groups a user is in
@ -206,9 +258,56 @@ marie steve
## Sysadmin tools
- How to create a symbolic link in Linux
To create a symbolic link to target file from link name,
you can use the ln command with -s option like this:
> ln -s target_file link_name
The -s option is important here. It determines that the link is soft link. If you dont use it, it will create a hard link. Ill explain the difference between soft links and hard links in a different article.
- Htop: Interactive processes viewer
> $ htop
- Changer default shell
> $ vim /etc/passwd
```bash
steve:x:1002:1002:,,,:/home/steve:/bin/bash
steve:x:1002:1002:,,,:/home/steve:/bin/fish
```
- |: pipe send result of the first command to the second
> cat /etc/passwd **|** **grep** bash |**cut** -d ":" -f1
- Grep: print lines that match patterns
> $
Search for specific text with grep command
> $ grep -l example document1.txt document2.txt
> $ grep -l example \*.txt
grep as long as you include the -r (recursive) option in the command.
> $ grep -lr example /path/to/directory1/\*.txt /path/to/directory2
Or, to search the current directory and all subdirectories, omit the path at the end of the command.
> $ grep -lr example
- Cut: remove sections from each line of files
> $
- Wc: print newline, word, and byte counts for each file
> $ wc -l
```bash
$ realpath example.txt
/home/username/example.txt
```
## text editor
- Nano: Nano's ANOther editor, an enhanced free Pico clone
(simple text editor for noobies)