Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Improving Your Shell Usage (2009 UWCS Intro Talk)

Improving Your Shell Usage (2009 UWCS Intro Talk)

Introduction to using a shell talk given to new UWCS members in 2009.

Chris Sinjakli

October 21, 2009
Tweet

More Decks by Chris Sinjakli

Other Decks in Programming

Transcript

  1. Learn how to get around Where am I? The pwd

    command will show you the current working directory:
  2. Learn how to get around Listing directory contents The ls

    command lists the contents of current directory:
  3. Learn how to get around Changing directory The cd command

    will change to the directory specified:
  4. Editing files Manually Usual choices of editors to use on

    the command line are: – nano – Tiny learning curve, shortcuts displayed by default – vim – Powerful, steeper learning curve, more features (my preferred editor) – emacs – I’ve never used it. Steep learning curve, powerful, lots of features.
  5. Command History A faster way to retype commands When you

    type commands into your shell, they are stored in a history file. You can access previous commands using the up arrow key. The down key obviously goes the other way in your history.
  6. Command History Searching through History You can also search through

    your history like you would use the "find" tool in a browser or text editor. Use Ctrl+R, and you should see something like this: As you type, it will narrow down hits in your history.
  7. Persistent Sessions with GNU Screen Allows you to leave things

    running on a machine which you want to come back to later. Some common use cases: – Working on a remote machine (via something like PuTTY) on an unstable connection. If you get disconnected, this will allow you to resume exactly where you left off – On your own linux machine when updating and restarting the graphical environment. The update program, if running in a graphical terminal (like gnome-terminal or xterm) will be killed partway through the process if you are not running them separately in screen. – Running programs on remote machines that won't run in the background. – Lurking in chat channels by running your IM clients on a machine that has more uptime than yours
  8. Persistent Sessions with GNU Screen Creating a session You can

    create a new session by just using the "screen" command.
  9. Persistent Sessions with GNU Screen Resuming a session The -r

    switch is used to reattach a screen session. $ screen -r [where you were in your previous session]
  10. Persistent Sessions with GNU Screen Resuming a session If you're

    already attached to a session from somewhere else, you'll see something like this: $ screen -r There are screens on: 15716.pts-4.viglab-26 (Attached) There is no screen to be resumed.
  11. Persistent Sessions with GNU Screen Resuming a session You can

    remote detach from this session, freeing it up for you to resume here. Use screen -d to do this, however we will insist on using -D because this both detaches the session and logs out the parent shell, which is far safer. $ screen -D [15716.pts-4.viglab-26 power detached.] You can of course combine the two switches 'screen -Dr' to remote detach, then reattach here.
  12. Persistent IRC connections – irssi in screen Starting irssi and

    connecting After creating a screen/attaching an previously created screen, run irssi. $ irssi In irssi, to connect to a server you use the /connect command as follows: /connect <Server Address>
  13. Persistent IRC connections – irssi in screen Joining a channel

    Having connected you’ll probably want to talk to people. You join a channel with /join. In this case we’ll join our main channel. /join #compsoc
  14. Persistent IRC connections – irssi in screen Switching channels To

    switch between channels is simple. Windows 1-19 can be accessed through pressing alt and either a number 1 to 0 above the letter keys or a letter between q and o (ie most of the top row of the qwerty keyboard). After that you simply use the command: /win <Window Number>
  15. Persistent IRC connections – irssi in screen Leaving a channel

    Leaving a channel is simple. Simply navigate to the correct window and run: /part <Quit Message>
  16. The End(ish) • You should be able to log into

    your UWCS shell account and get started. • Don’t be afraid to ask someone if you’re having problems, but the majority of the time there will be a good answer available if you google for your problem. • What I’ve talked about is only an introduction. This talk could probably last a year and still not cover everything. You will definitely pick things up as you go along. • Don’t be daunted by what might be a completely new way of using a computer for you. Simply having a go is the best way to learn! Onward to DCS!