Previously when studying at school, there were some subjects I had to do homework with ubuntu. But also just know how to use. When you need to use reality I just know google search and copy one line at a time. After a period of use, I began to learn and understand something. None of this tells anyone, it feels like everyone knows because it’s so basic. And now I write articles that everyone knows.
1 File permissions
1 2 | $ chmod 777 filename |
Nobody is any stranger to this chmod, but does anyone tell you what the 777 or 755 is. Probably not because no one has told me now. Like the default everyone knows. Then explain a bit. When you type ls -la
or short called ll
, you will get a list of files in directories like this.
1 2 3 4 5 6 7 | $ ll total 68K drwxr-xr-x 5 sandy sandy 4,0K Thg 3 30 16:25 Desktop -rw-r--r-- 1 sandy sandy 435 Thg 4 4 00:04 docker-compose.yml drwxr-xr-x 5 sandy sandy 4,0K Thg 3 27 13:44 Documents drwxr-xr-x 4 sandy sandy 4,0K Thg 4 16 14:57 Downloads |
You can see that the permissions section is drwxrwxrwx
. The first is the format of file d
is directory. Also there is l
link, and a few other formats. And followed by 3 rwx
clusters where r is read, w is write, x is execute. Each cluster will be a set of 3 bits with 1 to be enabled, 0 to disable. Obviously, if enabled the whole would be 111 = 7, or rx
only for read and execute but not for write will be 101 = 5.
So 755 will be rwxr-xr-x
, Now you know how to number when decentralized.
2 SSH key
When I first started working, I didn’t know anything about the server, I didn’t work on anything, just local code and pushed. But when I started to touch, I was told by TL to “send the ssh key to you to add”. Well and of course for a new guy, “what is the ssh key?”.
Basically, the ssh key is a private and public key pair that will be used instead of a password when ssh. I also did not go into the internal coding mechanism. You just need to give birth to this pair by:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | $ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/sandy/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/sandy/.ssh/id_rsa. Your public key has been saved in /home/sandy/.ssh/id_rsa.pub. The key fingerprint is: SHA256:TO+dsOPISqqThDqdKaEbxopgmqEOgf6JOwNDZbSSy1k <a class="__cf_email__" href="/cdn-cgi/l/email-protection">[email protected]</a> The key's randomart image is: +---[RSA 2048]----+ | .. | | .o. | | ooE . | |o.= o . | |+= S o | |B.. . + . | |OX + . + o | |#*O .o . o . | |OB==. ..o . | +----[SHA256]-----+ |
And copy the contents of the file ~ / .ssh / id_rsa.pub to the server and you can ssh.
Also ssh key is also used when you authen into github and deploy key on server. Quite a lot of applications if you will find out.
3 Command pipe
When I did a task before, I checked out a new branch. Gradually, the local branch was a mile long, then they had to be deleted, but deleted one by one until tomorrow because we only knew the command to delete each branch one by one. First I try to find out if git has any command that clears all branches. And I found one like this:
1 2 | git branch | grep -v "master" | xargs git branch -D |
And the magic here is the |
sign , it will make the output of the previous statement become input in the following statement. If used, there are really many convenient tricks that this seal brings. For example, filtering a large log file only a few days ago:
1 2 | cat development.log | grep "2020-04-22" |
Copy a series of files:
1 2 | ls | grep ab | xargs cp -t files/ |
There are also a bunch of special marks that you probably will need. https://www.howtogeek.com/439199/15-special-characters-you-need-to-know-for-bash/