The commands on ubuntu (80%) – part 2

Tram Ho

In the current information technology industry, technology skills, technical skills to learn and learn are the most basic part of all developers. In which, the skills of searching and learning are indispensable, do you recognize it? So many people from other disciplines can learn and learn, thanks to research and learning, to dev, to PM, bla bla …. and vice versa, ae dev if we are able to learn and learn their major, then Also can be big HR, big etc, cloudy, depending on your motivation. But in general, if I have big HR, my ability will not match those of HR, like a doctor with big teeth having a cast is still better than someone who knows nothing big. Ae admitted no.

With the skills of searching and learning, there are things that you and I think are ok, then at that time, the search will not stress. But no, that is not enough, there are extremely difficult search things, or do not know the keyword, but when it comes time to search, it is a bit tiring, so there are things that should be learned gradually, accumulated gradually, growing up. day by day to when it is needed, just bring to war. There is no need to ask if this one is available, whether it needs to be renewed, or made of …. rice. For example, finding a certain file in a certain directory, of a certain directory in a list of directories …. by searching for each directory is tiring, but if you know the find command (like the example in the previous post, link here ), everything looks good.

Come on continue to the main issue, ae. Start.


ln

ln command is a Linux system command used to create links. What’s the link? Create a link java antivirus?

Hong nha, this link can be considered an access point, a link for quick access to another file. Similar to Windows shortcuts. There are two types of links: hard links and soft links.

Hard links

This is rarely used, the limitation of this link is that you cannot create links to directories and also cannot link to external filesystem (disks). Syntax:

Another point is that a file is created with no known where it came from. It is more like a copy, the content is no different from the original.

But if you edit any file, the content will be updated in both files as well.

If you delete the original file, the contents of the unaffected file will still exist.

Soft links

Soft link on the other hand, it can link filesystems and folders, but when the source files are deleted, the link is also damaged. Syntax:

gzip

You can use gzip to compress a file with a protocol named LZ77 . Syntax:

If with the first command, when it is compressed it will delete the original file, when with -c option it will compress the file and add the .gz extension and not delete the original file.

With gzip has a few different compression levels, There are levels from 1 (fastest, worst compression) to 9 (slowest, best compression). and the default if not specified will be 6. This level is only really used when you have to compress a very heavy file when you have to think about good compression with a fast time which is better. Syntax:

Can compress multiple files at the same time:

Can compress all files in a directory:

Use the -kv option to display the compressed percentage.

gzip can also be used to unzip a file, using the -d option:

tar

The tar command is used to create a repository, where there are many files (like a directory containing many files). Syntax:

option c – create, f option is used to create the repository.

To extract, use the following cmd, where x is extract:

tar is often used to create an archive (create a repository and then re-compress) by 1 cmd:

And to unzip, use gunzip and then extract it, but with -xf it will do everything:

alias

Before going to learn alias, we go through the following example: for example with the default ls command it will print out a filename, and if using the -al option, it displays all the information of the files.

It doesn’t take much effort either, adding the -al option only so it doesn’t matter. But you can create a new cmd named ll is a combination of ls -al (first and last letter) for quick and convenient typing. And if it’s the following command: git show --pretty=short --show-signature then type it out. So is there a way to type quickly. Yes it is alias. Syntax:

But when typing this command, it only works in terminal session only if the computer is shut down or it will be lost to another user. Recommended to use put this in files: ~ / .bashrc or ~ / .profile or ~ / .bash_profile.

To view the available alias use: alias

cat

Similar to tail to view the contents of the file, except that cat can add the contents of the file.

For more information on line numbers use the -n option:

Tip: use with another command.

tail

Similar to cat to view the content of the file, but tail cannot add content and can see the content of the file as soon as the file changes (realtime), used to view the log. Common usage syntax:

Can show the last 10 lines

less

This is a 1 cmd I use very little, hardly use it because there are others that are more familiar and much easier to use are vim bleach and nanomaterials (micro – nano). Show interactive UI file contents. Syntax:

Use:

  • q – quit
  • up – up, down down, trái phải
  • going down the last line with G , top by g
  • search /keyword or ?keyword enter
  • edit – v

Like


Done. This is part 2. I will back this series later. You welcome to read part 3 link here. Thank you for your interest.

Share the news now

Source : Viblo