Tag: tutorials

  • Linux Tutorial Series – 33 – Auto-completion

    Here is the video version, if you prefer it:

    Let’s talk about how you can use auto-completion in the shell. When typing a filename, press Tab on your keyboard.

    Let’s say I have a file named longFileName.txt. I can just type in long, press Tab and the filename will be filled for me automatically. This does not hold if I have two or more files starting with long. There must be only 1 file with that prefix in its filename (any ambiguity must be cleared) for auto-completion to work.

    Hope you learned something useful!

  • Linux Tutorial Series – 32 – The ls command

    Here is the video version, if you prefer it:

    The ls command lists directory contents. (“ls(1) – Linux man page,” n.d.)⁠ Its usage goes as follows:

    mislav@mislavovo-racunalo:~$ ls

    anaconda3 Downloads Pictures stanfordnlp_resources

    'Calibre Library' grep-hadoop-example Public Templates

    Desktop hadoop-example Python-3.7.4 Untitled.ipynb

    Documents Music snap Videos

    A useful option of the ls command is -l. The -l option is the “long listing format”, which lists the following (from the first to the last column):

    • file permissions,
    • number of links,
    • owner name,
    • owner group,
    • file size,
    • time of last modification, and
    • file/directory name (“What do the fields in ls -al output mean?,” n.d.)⁠

    I use the ls -l option to find out the size of the files within a directory. My main concern is if the files are empty (0 bytes) or if they are larger. This is because I write programs and if a program is actually writing something to a file, the files should be larger than 0 bytes.

    An example output of the ls -l command is:

    mislav@mislavovo-racunalo:~/grep-hadoop-example$ ls -l

    total 4

    -rw-r--r-- 1 mislav mislav 22 Nov 9 18:32 part-r-00000

    -rw-r--r-- 1 mislav mislav 0 Nov 9 18:32 _SUCCESS

    The option I use less often, but is mentioned in the above reference is the -a option. The -a option flag lists all files, even the hidden files (hidden files are specific in that their filename starts with a .). I never had the need to look at hidden files as those are usually reserved for some operating system things or some program configuration things, but if you want to explore, off you go with ls -a! You can combine both the l option and the a option by writing ls -la. You can usually combine options like that.

    Hope you learned something useful!

    References

    ls(1) – Linux man page. (n.d.). Retrieved January 6, 2020, from https://linux.die.net/man/1/ls

    What do the fields in ls -al output mean? (n.d.). Retrieved January 6, 2020, from https://unix.stackexchange.com/questions/103114/what-do-the-fields-in-ls-al-output-mean

  • Linux Tutorial Series – 31 – The –help option

    Here is the video version, if you prefer it:

    If you don’t want to read through man pages of a command to find out how it is used, you can specify the --help flag (its equivalent short option is -h) when executing a command, which will give you a description of how the command is used in a very concise and clear way.

    Not all (executable) commands support the --help flag, but I found myself using --help more often than man.

    Thank you for reading and hope you learned something useful!

  • Linux Tutorial Series – 30 – Long and short command options

    Here is the video version, if you prefer it:

    When talking about the general command structure:

    command -options arguments

    I wanted to note that you can have two kinds of options: short options and long options. Long options use two dashes (--) and can’t be chained together, while short options use only one dash and can be chained together. What this means is that if I wanted to display all files in the current directory alongside their long listing, I could write:

    ls -l -a

    or, shorter:

    ls -la

    However, long options (one of which we will talk about in the next post) can’t be chained. Just keep that in mind.

    Hope you learned something useful!

  • Linux Tutorial Series – 29 – The man command

    Here is the video version, if you prefer it:

    The man command is used to display usage information regarding a certain command. (“man(1) – Linux man page,” n.d.)⁠ For example, if I wanted to know how to use the ls command, I would write:

    mislav@mislavovo-racunalo:~$ man ls

    The man page for the ls command would open and then you can see the usage information regarding the ls command. You could scroll through the man page by using Space on your keyboard (to move forward one page) and Q to exit man page viewing. To go backward for 1 page, press B. The answer in the reference here says to press CTRL + B (or ^B in Linuxspeak), but you can just press B. (as is said in the comment in the reference; it is always good to read stackexchange comments!) (“How to read backward from the end of file in less or more?,” n.d.)⁠

    That way, if you forget to use a command, you can always find out its usage information. Although I have found myself very rarely using the man command (because I know the syntax of the commands I often use by heart, or use Google to find their usage in my particular situation), it can come in handy to know that you can always have the man there waiting for you if all else fails.

    Hope this helped!

    Additional information tidbit:

    You can even access the man pages of man by writing man man. Manception!

    References:

    How to read backward from the end of file in less or more? (n.d.). Retrieved January 6, 2020, from https://serverfault.com/questions/151635/how-to-read-backward-from-the-end-of-file-in-less-or-more

    man(1) – Linux man page. (n.d.). Retrieved January 6, 2020, from https://linux.die.net/man/1/man

  • Linux Tutorial Series – 28 – The cd command

    Here is the video version, if you prefer it:

    The cd command is used to change the working directory. Its name, cd, literally stands for “change directory”.(“cd(1) – Linux man page,” n.d.)⁠

    For example, if I wanted to go to folder named Downloads relative to my current directory, I would write:

    mislav@mislavovo-racunalo:~$ cd Downloads

    However, let’s say I was somewhere far, far away from my Downloads folder. Let’s say I was in somewhere like /usr/local/bin. Pretty tough to navigate from here to my Downloads folder (not impossible, but tedious – I would have to write cd .. to go to the parent folder, then repeat that multiple times until I reached the root folder, then cd myself into home and then mislav and then finally Downloads). Here I would use:

    mislav@mislavovo-racunalo:/usr/local/bin$ cd /home/mislav/Downloads

    and I would get to my desired Downloads folder without a lot of navigation.

    To emphasize: You can always use cd .. to go to the parent folder of the current directory and then use cd someFolder to position yourself in the folder someFolder.

    Hope this was helpful!

    P.S. To be honest with you, I usually change directories the tedious way, as in writing cd .. and cd SomeFolder a lot of times, but I believe that it is much easier to get the work done with providing an absolute pathname. So this is some “I advise doing this even if I do this the other way” type of advice.

    References

    cd(1) – Linux man page. (n.d.). Retrieved January 5, 2020, from https://linux.die.net/man/1/cd

  • Linux Tutorial Series – 27 – The pwd command

    Here is the video version, if you prefer it:

    pwd prints the name of the current working directory. This is useful when changing directories with cd and you want to know where you are. For example:

    mislav@mislavovo-racunalo:~/Documents$ cd django-rest-tutorial

    mislav@mislavovo-racunalo:~/Documents/django-rest-tutorial$ pwd

    /home/mislav/Documents/django-rest-tutorial

    pwd stands for “print working/current directory”. (“pwd(1) – Linux man page,” n.d.)⁠

    Hope this was useful!

    References

    pwd(1) – Linux man page. (n.d.). Retrieved January 5, 2020, from https://linux.die.net/man/1/pwd

  • Linux Tutorial Series – 26 – Commands are case sensitive

    Here is the video version, if you prefer it:

    Before we begin learning the commands we are about to learn, let me just note that the commands are case sensitive. Meaning – it is not the same if you use uppercase or lowercase letters in command names.

    Keep this in mind.

    Talk soon!

  • Linux Tutorial Series – 25 – General command structure

    Here is the video version, if you prefer it:

    Before we begin learning the commands, let me tell you that commands generally look like this: (Shotts, 2019)⁠

    command -options arguments

    Keep this in mind as you progress through the following posts.

    Thank you for reading!

    References

    Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Page 38

  • Linux Tutorial Series – 24 – Checkpoint

    Here is the video version, if you prefer it:

    In the following posts, we are going to cover a lot of commands. Those commands are the bread-and-butter of the Linux command line. You will use them almost daily and almost every tutorial on how-to do something on Linux uses these commands and so it is very important to understand what they do, since most tutorials assume you know what they do.

    I will not lie – this will be a little bit dry. However, treat it as learning to add and subtract. It is not fun at the time you are learning it, but you power through it. I am asking you to power through it a little bit. It will pay off.

    See you on the other side!