CommandLineBasics

User Days Command Line Basics Session

Shell, Bash

  1. What is a shell.
  2. What is bash, Bourne again shell, Bourne shell
  3. Other shells, dash
  4. builtins, programs and processes

Key Concept: Where am I?

  1. Where am I?
  2. Let's go somewhere else.
  3. What is here?
  4. Viewing the content of a file.
  5. Moving files and directories.

Short Cuts or How to Not Type So Much

  1. tab completion
  2. aliases
  3. history

Getting information

  1. apropos
  2. man and info

Getting a Little Fancy

  1. Piping to less.
  2. Redirecting output to a file.
  3. Basic grep.
  4. Finding and killing a process

Some Tools

  1. A file manager: midnight commander.
  2. A web browser: lynx and/or links.
  3. An email client: alpine.

References

  1. tldp.org
  2. Learning the Bash Shell
  3. What are you forgetting Mark?

   1 === _marx_ changed the topic of #ubuntu-classroom to: Ubuntu Classroom Chat || Ubuntu User Days | Current Session: Command Line Basics ~~ Presented by _marx_ || Please ask questions here; prefix your question with QUESTION || Ubuntu User Days Survey: http://www.surveymonkey.com/s/WQWHJQY
   2 [14:00] <_marx_> Welcome everyone to Command Line Basics
   3 [14:00] <cjohnston> Up next we have _marx_
   4 [14:00] <cjohnston> Mark Cox lives in Winston-Salem, North Carolina. He has made his living as a carpenter since getting out of the Army in '85.
   5 [14:00] <cjohnston> He has been using Linux since 1998. Mark has been using Ubuntu since 5.04. He hopes to be unique by being the first Grandfather in recorded history
   6 [14:00] <cjohnston> to convert his grandsons to Ubuntu instead of the other way around. Mark's two oldest grandchildren were dazzled by "the cube" over the holidays.
   7 [14:01] <_marx_> thanks cjohnston
   8 [14:01] <_marx_> Today I just want to cover some basics.
   9 [14:01] <cjohnston> < mick__> Question:: shell programming::  any good tutorials online to take you from newbie to MOTU?
  10 [14:01] <cjohnston> Got an early question for you. ;-)
  11 [14:02] <_marx_> Hopefully when we're done you be able to survive the dreaded no X experience.
  12 [14:02] <_marx_> mick__, the linux documentation project bash
  13 [14:03] <_marx_> First a little lecture time.
  14 [14:03] <_marx_> Then we'll do some things
  15 [14:03] <_marx_> When we use the command line we are using a shell.
  16 [14:03] <_marx_> In this context a shell is the most basic way a user can interact with a computer's operating system kernel.
  17 [14:04] <_marx_> A shell is a piece of software.
  18 [14:04] <_marx_> Most GNU/Linux distributions use the Bourne Again SHell (bash) as the login shell.
  19 [14:05] <_marx_> The again part is because the first iteration was called the Bourne SHell (sh) which was released for unix in the late '70's
  20 [14:05] <_marx_> Beginning with the 6.10 release Ubuntu began using dash (the Debian Almquist Shell) as the default system shell.
  21 [14:05] <Pendulum> Jedemco> Question: Is a "shell" also the "Terminal" in Ubuntu?
  22 [14:05] <_marx_> The default login shell is still bash.
  23 [14:06] <_marx_> Jedemco, yes for all practical purposes
  24 [14:06] <_marx_> when one opens say gnome-terminal you'll be using bash
  25 [14:07] <_marx_> Today we will learn how to navigate the Linux file system,
  26 [14:07] <_marx_> view the contents of a file,
  27 [14:08] <_marx_> opy and rename files and directories,
  28 [14:08] <_marx_> userdays3, yes
  29 [14:10] <_marx_> pipe output of one command to another, direct output to a file,
  30 [14:10] <_marx_> install programs, navigate the internet all via the command line interface.
  31 [14:10] <_marx_> Maybe we'll get to all of that!
  32 [14:10] <_marx_> For our exercises today I will be using the Gnome terminal.
  33 [14:10] <_marx_> I want to make opening a terminal a click or two faster so click Applications > Accessories and drag Terminal into your top panel.
  34 [14:11] <_marx_> This is just to make starting a terminal a little faster by not using the menu system
  35 === nigel_nb is now known as Guest70547
  36 [14:11] <_marx_> I'm not real familiar with KDE and Xfce so maybe just drop the icon on the desktop to create a launcher.
  37 [14:12] <Pendulum> < userdays3> QUESTION:Is there a difference between a system shell and a login shell?
  38 [14:12] <_marx_> lannocc, makes starting a terminal little quicker
  39 [14:13] <_marx_> There can be a difference between the system shell and login shell; on Ubuntu they are different.
  40 [14:13] <_marx_> ow let's open a terminal session, just click the icon we just created in the top panel.
  41 [14:14] <_marx_> Everyone have a terminal open?
  42 [14:14] <_marx_> I'm going to try to remember to wrap all my command examples with quotes around them so just type whatever is inside the quote marks.
  43 [14:15] <_marx_> I may forget so pay attention :-)
  44 [14:15] <_marx_> Okay first command "whoami"
  45 [14:15] <_marx_> Well now you know who you are!
  46 [14:17] <_marx_> Concept Where am I!
  47 [14:17] <_marx_> This is an important unix concept.
  48 [14:17] <_marx_> Where am I in the file system?
  49 [14:17] <_marx_> Let's use print working directory to find out. "pwd"
  50 [14:18] <_marx_> everyone should be in their home directory.
  51 [14:19] <_marx_> Okay, what's here? Use the list command to list the contents "ls"
  52 [14:20] <_marx_> no pm's please
  53 [14:20] <_marx_> ask in -chat
  54 [14:21] <_marx_> Commands can take options.
  55 [14:21] <_marx_> Try `ls -l`
  56 [14:22] <_marx_> now we get a long listing of all the files and directories
  57 [14:22] <_marx_> But this isn't all the files use `ls -a` to see all the files
  58 === Walt is now known as Guest71766
  59 [14:23] <_marx_> Okay let's go somewhere else; `cd /`
  60 [14:23] <_marx_> and let's do a long listing of all the files
  61 [14:23] <_marx_> answer in -chat
  62 [14:24] <_marx_> any one long listing of all files
  63 [14:24] <_marx_> well it's `ls -al`
  64 [14:25] <_marx_> and where are we now?
  65 [14:25] <cjohnston> < doxdrum> Question - is it important the order of the options? -al or -la
  66 [14:25] <_marx_> doxdrum no
  67 [14:26] <_marx_> everyone should be in "/" now.
  68 [14:26] <_marx_> pwd to find out where you are
  69 [14:27] <_marx_> well not seeing responces to where one is in -chat
  70 [14:28] <_marx_> okay let's all go home with `cd`
  71 [14:28] <_marx_> the command `cd ~` will also work
  72 [14:28] <_marx_> now `cd -`
  73 [14:28] <_marx_> and where are we?
  74 [14:29] <_marx_> that was a dash or minus sign
  75 [14:29] <_marx_> yep; "cd -" will take you back to the last directory you were in
  76 [14:30] <_marx_> ok go home
  77 [14:30] <_marx_> and list all files
  78 [14:30] <_marx_> we're gonna shorten up on some of this typing
  79 [14:31] <_marx_> `less .bashrc` will let you view your bashrc file
  80 [14:31] <_marx_> use "q" to quite less
  81 [14:31] <_marx_> we can shorten up on alot of typing by using aliases
  82 [14:32] <_marx_> type `alias` to see what aliases are set now
  83 [14:32] <_marx_> everyone have a output of current aliases?
  84 [14:34] <_marx_> oka to set an alias try "alias 'l=ls -l'"
  85 [14:35] <_marx_> now just type "l"
  86 [14:36] <_marx_> good question hhlp
  87 [14:36] <_marx_> it is not permenamt
  88 [14:36] <_marx_> ow bad spelling
  89 [14:37] <_marx_> to make an alias permenant
  90 [14:37] <_marx_> we need to edit ~/.bashrc; that file we just viewed with less
  91 [14:38] <_marx_> assuming everyone is in there home directories do "nano .bashrc"
  92 [14:39] <Pendulum> < Crewsr3> so when you set up an alias without editing the .bashrc file how long will the alias work?
  93 [14:39] <_marx_> go to the end of the file and add the line "alias 'l=ls -l'"
  94 [14:40] <_marx_> Crewsr3, until you logout of the shell/bash session.
  95 [14:40] <_marx_> 20 minutes to go: how are we on nano w/.bashrc?
  96 [14:41] <_marx_> everyone have that line in .bashrc
  97 [14:41] <_marx_> save and exit the file
  98 [14:41] <_marx_> now bash doesn't know we've changed it's config file
  99 [14:42] <Pendulum> < Yos> how to save and exit ?
 100 [14:42] <_marx_> in nano ctl-x to save and exit
 101 [14:43] <_marx_> so to make bash aware that we've changed it's config file we need to source the config file
 102 [14:43] <_marx_> do that with "source .bashrc"
 103 [14:45] <_marx_> so now you could open a second terminal and "l" should give you the same as "ls -l"
 104 [14:45] <_marx_> well i'm not going to get to everything i wanted to so questions?
 105 [14:46] <_marx_> Question: command to check available disk space
 106 [14:47] <_marx_> i like `df -h` and i usually alias df to that
 107 [14:47] <_marx_> ah info on commands can be found several ways
 108 [14:47] <_marx_> man <command> info <command>
 109 [14:48] <Pendulum> < Jedemco> Question: I don't understand the concept of "alias." What is it and what does it do for me?
 110 [14:48] <_marx_> alias example: `alias 'df=df -h'`
 111 [14:49] <_marx_> an alias is like a shortcut; instead of typing all the options for a command we can type one or two letters to do the command
 112 [14:50] <_marx_> for the brave "sudo apt-get install mc"
 113 [14:50] <_marx_> this will install the midnight commander file manager
 114 [14:50] <_marx_> it can also do ftp and sftp
 115 [14:51] <cjohnston> < Yos> Question what is the difference between bash and screen byobu ?
 116 [14:51] <_marx_> screen is like a console or command line window manager
 117 [14:52] <_marx_> screen starts within a bash session
 118 [14:53] <_marx_> anyone install mc?
 119 [14:53] <_marx_> start mc with `mc`
 120 [14:53] <cjohnston> < Jedemco> Question: how do I get to "screen"?
 121 [14:54] <_marx_> Jedemco, just type `screen`
 122 [14:54] <cjohnston> _marx_: is screen installed by default?
 123 [14:54] <_marx_> start mc with `mc`
 124 [14:54] <_marx_> cjohnston, not sure
 125 [14:54] <cjohnston> I believe they would need to install first?
 126 [14:55] <_marx_> we could do 30 minutes on mc probably
 127 [14:55] <cjohnston> 5 minutes left in this session
 128 [14:56] <_marx_> some other command line goodies are lynx for a web browser
 129 [14:56] <_marx_> and alpine for an email client
 130 [14:57] <_marx_> three minutes left thanks everone of coming by today
 131 [14:58] <_marx_> hopefully some of this was helpful

UserDays/01232010/CommandLineBasics (last edited 2010-01-24 00:23:01 by alderaan)