Linux

Simple Tips: Working With The Shell

Working with Shell is fun! But what is Shell? Before the introduction of the graphical user interface (GUI), Linux provided only textual interface (command line interface ( CLI )). Today, a Textual interface is available when logging in from a terminal emulator.

Logging in from terminal

Today, most Linux distribution (e.g. Ubuntu) comes with “login manager” (e.g. GDM, KDM, XDM). But when you are using a distro that doesn’t come with GUI, you probably don’t have these login managers so you have to login from terminal.  You should see this

Archlinux 3.0 -ARCH (nmepntgrm) (tty1)

nmepntgrm login:  myusername

password:

Last Login: Wed Mar 10 19:09:59 on tty1

[myusername@nmepntgrm~]$

Security Tip: See the “Last Login:” line? That’s the date , time and place you last login. If the date and time is somewhat strange, you must change your password. The place here is tty1- if you don’t know what tty1 means, that is the virtual terminal number, you can work up with many terminals, switching tty will be Ctrl + Alt + (Function number) e.g

Ctrl + Alt + f2

Will lead you to tty2. So it means many workspace in shell! How nice is that? tty1 editing using emacs , tty2 typing in commands, tty3 listening to music etc.. But when the place is not tty, it is the computer name (e.g nmepntgrm, mycomp), it means you last login from different computer.

 

Logging in from the network is the just same, you can use either telnet or ssh.

 

Note: Telnet is not secure! One reason telnet is not secure is that it send your username and password over the network in cleartext when you log in. SSH encrypts all information it send over the network so better to use ssh over telnet if possible. Example of ssh log in:

$ ssh myusername2@nmepntgrm

password:

Last login: Wed Mar 11 20:02:06  on nmepntgrm

[myusername@nmepntgrm myusername2]$

Erasing A Character:

Erasing a character sometimes bit annoying, but with this shorcuts you will love to erase :p.

BACKSPACE  – deletes one character thesame as DEL

Ctrl+h              – deletes one character, more easy to delete than backspace

Ctrl+w             – deletes a word (characters until the last space or tab)

 

Closing, Suspending A Running Program:

Ctrl + z  – suspends the running program

e.g

$ emacs -nw

[1]+  Stopped                 emacs -nw

$ jobs

[1]+  Stopped                 emacs -nw

$ fg

emacs -nw

$ kill -TERM %1

[1]+  Terminated              emacs -nw

jobs will list the running jobs, fg will continue the stopped job, kill -TERM %1  will kill (oh brutal) a job.

Ctrl + c will close a program, but you cannot close some app with this (e.g emacs)

That’s All for now, I will discuss the power of su/sudo on my next post 🙂

Happy Hacking!

I started blogging around 2011 at #Ubuntupirates, #ProjectX and #pir8geek, I’m currently working as Network/Linux SysAdmin.

I’m a Linux,opensource advocate and interested in network security and InfoSec.

5 Comments

  1. Just adding…

    It should also be important to note that F7 is reserved for your GUI. And on some distros, F8 is ALSO reserved for your GUI. In some distros(like Fedora, F7 and F1 reference the same workspace.

    The “Erasing a Character” section is a bit misleading. These shortcuts are specific to bash. Though Ctrl+W also works for tclsh. Not all shells are created equal and more importantly, not all shells have the same keyboard shortcuts.

    You’ve mentioned suspending a program. While fg is sufficient if you have only one suspended job, for cases wherein there’s more than one, you need to pass the associated job number.

    pts/n may also mean a shell session that’s currently active in your local machine. i.e. shell was not opened remotely.

    HTH.

    Reply
  2. I want to say thank you very much for your work you have made in writing this posting. I am hoping the same effective job by you in the future as well.

    Reply

Leave a Reply