Category: /chris/linux

Terminal productivity boost (some Bash aliases)

Hello again,

It’s been a long time since I’ve posted, but it’s been a really busy period..


An icon representing a terminal prompt
Terminal prompt

On to the topic, using a feature such as aliases in a terminal, certainly makes you do things faster.
(To get an intro to aliases and a guide on how to save them permanently, read this)

So I’ve gathered some of mine and uploaded them at Github as a bash-aliases repo.

Here are some:

Installation:

Append them over to your ~/.bash_aliases file

Read More

GNU/Linux SSH login script for my university’s linux-lab

This is a post regarding an ssh login script I wrote, for the GNU/Linux machines at the linux-Lab of my department. More about the script here.

Update:
Πρόσθεσα δυναμικό έλεγχο των linux machines. Με wget κατεβάζω το html αρχείο και έπειτα διατρέχω τα linux_machines και δοκιμάζω ssh.
Στο τέλος, διαγράφονται τα αρχεία των linux_machines, για να γίνει επανέλεγχος κάθε φορά.


Έγραψα ένα scriptaki για automated ssh login στα linux μηχανήματα της σχολής.
Είναι καλό να ακολουθήσετε πρώτα τις οδηγίες για passwordless ssh connection που βρίσκονται εδώ ώστε να μην χρειάζεται κάθε φορά να πληκτρολογείτε τον κωδικό σας για κάθε μηχάνημα.

Λόγος/Ιδέα:

Προσπαθούσα να συνδεθώ στη σχολή μέσω ssh και απέτυχε σε 2 μηχανήματα (ήταν down νομίζω τα συγκεκριμένα linux) οπότε σκέφτηκα να φτιάξω ένα scriptaki που θα κάνει το polling για μένα.

Τρόπος λειτουργίας: 

Ουσιαστικά αρχίζει δοκιμάζοντας ssh σύνδεση από το linux01 και φθάνει μέχρι το linux29 (όπως φαίνεται εδώ (current state των linux machines) ).
Αν η σύνδεση είναι επιτυχής, μόλις γίνει το exit από τον remote host σταματάει και το script, αλλιώς συνεχίζει μέχρι να έχει hit ή να φθάσει στο linux29.

Μπορεί να διακοπεί με Ctrl + c.

Read More

Performing SSH login without typing your password (via ssh-keygen & ssh-copy-id)

We all know SSH and have used it to connect to remote hosts.

The annoying thing about it (when using it frequently) is that you have to enter your password each time.

If you want to bypass that, as I wanted, keep reading..

  1. Firstly, on your local machine type this:  ssh-keygen
  2. You will be prompted to “Enter file in which to save the key
    just hit [enter].If you don’t want to assign a pass phrase (press [enter] key twice). It will create 2 files in ~/.ssh directory as follows:

    • ~/.ssh/id_rsa : identification (private) key
    • ~/.ssh/id_rsa.pub : public key

     

  3. Now we want to secure copy the public key to the remote host.
    We’ll do that with ssh-copy-id:
    ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-host
  4. Finally, you are able to login to the remote host using ssh username@remote-host without typing your password.

Run your own scripts from any directory when using terminal

We all know that scripts are a very handy way to get repetitive jobs done quicker (and much more).

Now, let’s suppose you have a script located at /path/to/dir directory.
Each time you need to run the script you would:

  1. Open a terminal
  2. change dir to /path/to/dir and then
  3. run your script using “./myscript” notation
  4. Or (a “faster” alternative) writing “/path/to/dir/myscript” to execute it

It might doesn’t look that much to do, but when you’re using it frequently, it can save time to just open a terminal and type “myscript” to run it.

Read More

Create permanent aliases at Ubuntu

A very handy and time-saving facility when using the terminal, is to use alias for any command that you use most of the time.

For example, at my system I have these aliases:

  • c == clear (also, a great keyboard shortcut exists: Ctrl + L)
  • e == exit
  • ls == ls -l –color=auto (flags explained below)

So if I want to clear the screen I only type “c”, hit enter…

Read More