Tag: Operating systems

  • Linux Tutorial Series – 44 – The less command

    Here is the video version, if you prefer it:

    The less command is used to paginate through contents of a text file. (Ward, 2014)⁠ You navigate it by using the following keys (these are the most important):

    • Space for page down
    • B for page up (no need to keep Caps Lock on; just press B on your keyboard)
    • Q for quitting less

    As you can probably suppose, less is better to use when reading text files than cat, because it outputs them more conveniently; it doesn’t just dump the contents of the file to your screen like cat does.

    Fun fact: man uses less (“Does man command invoke less command to display manual contents?,” n.d.)⁠

    Hope you learned something new!

    References

    Does man command invoke less command to display manual contents? (n.d.). Retrieved January 8, 2020, from https://askubuntu.com/questions/322851/does-man-command-invoke-less-command-to-display-manual-contents

    Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Page 19

  • Linux Tutorial Series – 43 – Did you see it yet?

    Here is the video version, if you prefer it:

    Heya,

    did you notice the general command structure? To remind you, it looks like:

    command -options arguments

    Let’s take a look at the commands we learned so far, applying the abstract command structure over them:

    • cd arguments
    • pwd
    • man arguments
    • ls options

    I hope this helped shed light on the underlying general command structure.

    Talk soon!

  • Linux Tutorial Series – 42 – The cat command

    Here is the video version, if you prefer it:

    The cat command is used to view contents of a file. More specifically, the cat command reads the contents of one or more files and copies them to standard output. (Shotts, 2019)⁠ 

    Here is an example of its usage:

    mislav@mislavovo-racunalo:~/Documents$ cat test.txt

    Something

    Something on another line

    This was a short text file, but for large files, output of cat is messy. There are other commands (such as less) which also show you the contents of a file, but in a much more convenient fashion. We will talk about these other commands very soon.

    Hope you learned something new!

    References

    Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 83-85

  • Linux Tutorial Series – 41 – The echo command

    Here is the video version, if you prefer it:

    The echo command is used to print its arguments to standard output. (Ward, 2014)⁠ “Standard output” is, in most cases, another word for “your monitor”.

    It is used like this:

    echo somethingToEcho

    For example:

    mislav@mislavovo-racunalo:~$ echo Wondering my usefulness, reader? Well, I will be useful later on, for now, just remember that I exist!

    Wondering my usefulness, reader? Well, I will be useful later on, for now, just remember that I exist!

    Oh my God, the command can talk! It is actually accurate in what it said – it is useful, but later when you learn about things such as expansions of shell globs. But that’s for another post.

    Hope you learned something useful!

    References

    Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Page 16

  • Linux Tutorial Series – 40 – The rmdir command

    Here is the video version, if you prefer it:

    The rmdir command is used to remove empty directories. (Barrett, 2016) Its usage is as follows:

    rmdir emptyDir1

    or (for deleting multiple empty directories):

    rmdir emptyDir1 emptyDir2 …

    Note that rmdir only removes empty directories. To remove directories that contain files, use rm -r, but please do remember to use it with extreme caution!

    Thank you for reading and hope you learned something useful!

    References

    Barrett, D. J. (2016). Linux pocket guide (3rd ed.). O’Reilly Media. Page 55

  • Linux Tutorial Series – 39 – The mkdir command

    Here is the video version, if you prefer it:

    The mkdir command is used to create a directory (or directories). (Shotts, 2019)⁠ Its usage is as follows:

    mkdir dir1

    for one directory, or

    mkdir dir1 dir2 …

    for multiple directories.

    Hope you learned something useful!

    References

    Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 58-59

  • Linux Tutorial Series – 38 – The touch command

    Here is the video version, if you prefer it:

    The touch command is used for changing file timestamps (or creating new files). (“touch(1) – Linux man page,” n.d.)⁠ It is used as follows:

    touch fileName

    If the file named fileName does not exist, the file with the name fileName is created. If the file named fileName already exists, then only its modification time is modified to the current time.

    I have used the touch command a few times to create new files.

    Hope you learned something new!

    References

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

  • Linux Tutorial Series – 37 – Be careful with rm

    Here is the video version, if you prefer it:

    In order to emphasize what can happen if you are not careful while using the rm command, I will tell you a story where I used rm the wrong way.

    I was mangling with some drivers. Everything was going fine. I was deleting some files, adding some new files. Nothing fancy. However, at one point, I was a little bit distracted and pressed Enter while I had an instance of the rm command in my Terminal. With that, I just deleted some very important graphics driver files. Ooops!

    Obviously, I tried to bring it back, but if you Google something like “how to restore files deleted with rm” you will find that while there are ways, they are all pretty complicated and involve a lot of hassle. That’s what happens when you aren’t careful. I had to reinstall my operating system to fix the issue caused by one accidental rm.

    So, once again: Be careful with rm. rm does not forgive.

    Thank you for reading!

  • Linux Tutorial Series – 36 – The rm command

    Here is the video version, if you prefer it:

    The rm command is used to delete files and directories. (Shotts, 2019) It is used as follows:

    rm item1 …

    where item1 can be either a file or a directory, and signifies you can specify multiple files or directories.

    Two options I found very useful with rm: -i is used to prevent rm from silently deleting files by prompting you before actually deleting them and -r is used for recursive deletion (meaning that both a directory and its subdirectories will be removed).⁠

    Be very careful with rm! Let me say that again: Be very careful with rm! rm does not forgive! I highly recommend checking out (“Where do files go when the rm command is issued?,” n.d.)

    Hope you don’t accidentally delete some files with rm and hope you found this useful!

    References

    Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 55-57

    Where do files go when the rm command is issued? (n.d.). Retrieved January 6, 2020, from https://unix.stackexchange.com/questions/10883/where-do-files-go-when-the-rm-command-is-issued

  • Linux Tutorial Series – 35 – The mv command

    Here is the video version, if you prefer it:

    The mv command is used to move or rename files or directories, depending on its usage. (Shotts, 2019)⁠ To rename or move files or directories, use it like this:

    mv oldFileName newFileName

    If you want to move one or more files from the source directory to the destination directory, use:

    mv file1 file2 … desination

    A couple of remarks: Use the -i option to prevent the mv command from silently overwriting files (files are overwritten when they have the same name in both the source and the destination) and use the -u option only move files that either don’t exist or are newer than the corresponding files in the destination directory.

    Hope you learned something useful!

    References

    Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 54-55