Small, Simple Trick in Linux

A few days ago, having looked at and studying a script code written by the lecturer to test our code, I would say that it did re-ignite my interest in shell scripting on Linux. Aspirations to be proficient in Linux system administration aside, I did find it a hassle when having to access a command-line to-do list tool, Todo.txt, in my Dropbox folder via the Terminal to update my to-do list daily. This involves passing a long directory path string to ‘cd’ command repeatedly, which can be annoying if you are in a hurry.

Doing a few Google searching on the VERY BASIC syntax of shell scripting allowed me to write a very simple program which i can simply run by opening the Terminal in my desktop. The script also repeatedly asks for commands until I enter a blank line, which saves a few hassle of using Todo.txt, which requires that I create an alias such as “alias t=./todo.sh” or enter ./todo.sh before any of the application’s commands. This saved me quite a bit of typing.

So what is a shell script? It is essentially a file wich, on execution, runs all UNIX/Linux commands contained inside the file sequentially, conditionally, or controlled by loops. Pretty much like any programming language in terms of semantics. What good is it for? Scripts can be used to run a set of MANY commands, called a batch process, which you wouldn’t want to enter them one by one by hand(it will be a pain to do so and these processes can take a long time). An immediate example I can think of is when you have just migrated from a Linux distribution to a new one. Surely, you do have a decently long list of packages that you use frequently and you will want to install them on your new Linux distro. With scripting, you do not have to remember this long list of packages and forget to install some of them in the process, especially if you have been using the previous distro for a very long time. Also, the only times when you need to respond are when the system prompts you to continue with the installation. This does not remove all inconveniences, but it does save you LOTS of typing and memory work on your part. Hopefully after this hectic semester is over, I can devote time to improving my skills as a Linux system administrator.

For the very experienced Linux users, pardon me if this sounds too basic or noob to you. You are free to ignore this or comment on any point mentioned which you felt it was wrong. For fellow beginners of Linux OS, I hope this helps in making life with the Terminal more convenient,

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s