CommandLineBasics

Revision 3 as of 2010-01-23 16:16:57

Clear message

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?

=== _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
[14:00] <_marx_> Welcome everyone to Command Line Basics
[14:00] <cjohnston> Up next we have _marx_
[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.
[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
[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.
[14:01] <_marx_> thanks cjohnston
[14:01] <_marx_> Today I just want to cover some basics.
[14:01] <cjohnston> < mick__> Question:: shell programming::  any good tutorials online to take you from newbie to MOTU?
[14:01] <cjohnston> Got an early question for you. ;-)
[14:02] <_marx_> Hopefully when we're done you be able to survive the dreaded no X experience.
[14:02] <_marx_> mick__, the linux documentation project bash
[14:03] <_marx_> First a little lecture time.
[14:03] <_marx_> Then we'll do some things
[14:03] <_marx_> When we use the command line we are using a shell.
[14:03] <_marx_> In this context a shell is the most basic way a user can interact with a computer's operating system kernel.
[14:04] <_marx_> A shell is a piece of software.
[14:04] <_marx_> Most GNU/Linux distributions use the Bourne Again SHell (bash) as the login shell.
[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
[14:05] <_marx_> Beginning with the 6.10 release Ubuntu began using dash (the Debian Almquist Shell) as the default system shell.
[14:05] <Pendulum> Jedemco> Question: Is a "shell" also the "Terminal" in Ubuntu?
[14:05] <_marx_> The default login shell is still bash.
[14:06] <_marx_> Jedemco, yes for all practical purposes
[14:06] <_marx_> when one opens say gnome-terminal you'll be using bash
[14:07] <_marx_> Today we will learn how to navigate the Linux file system,
[14:07] <_marx_> view the contents of a file,
[14:08] <_marx_> opy and rename files and directories,
[14:08] <_marx_> userdays3, yes
[14:10] <_marx_> pipe output of one command to another, direct output to a file,
[14:10] <_marx_> install programs, navigate the internet all via the command line interface.
[14:10] <_marx_> Maybe we'll get to all of that!
[14:10] <_marx_> For our exercises today I will be using the Gnome terminal.
[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.
[14:11] <_marx_> This is just to make starting a terminal a little faster by not using the menu system
=== nigel_nb is now known as Guest70547
[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.
[14:12] <Pendulum> < userdays3> QUESTION:Is there a difference between a system shell and a login shell?
[14:12] <_marx_> lannocc, makes starting a terminal little quicker
[14:13] <_marx_> There can be a difference between the system shell and login shell; on Ubuntu they are different.
[14:13] <_marx_> ow let's open a terminal session, just click the icon we just created in the top panel.
[14:14] <_marx_> Everyone have a terminal open?
[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.
[14:15] <_marx_> I may forget so pay attention :-)
[14:15] <_marx_> Okay first command "whoami"
[14:15] <_marx_> Well now you know who you are!
[14:17] <_marx_> Concept Where am I!
[14:17] <_marx_> This is an important unix concept.
[14:17] <_marx_> Where am I in the file system?
[14:17] <_marx_> Let's use print working directory to find out. "pwd"
[14:18] <_marx_> everyone should be in their home directory.
[14:19] <_marx_> Okay, what's here? Use the list command to list the contents "ls"
[14:20] <_marx_> no pm's please
[14:20] <_marx_> ask in -chat
[14:21] <_marx_> Commands can take options.
[14:21] <_marx_> Try `ls -l`
[14:22] <_marx_> now we get a long listing of all the files and directories
[14:22] <_marx_> But this isn't all the files use `ls -a` to see all the files
=== Walt is now known as Guest71766
[14:23] <_marx_> Okay let's go somewhere else; `cd /`
[14:23] <_marx_> and let's do a long listing of all the files
[14:23] <_marx_> answer in -chat
[14:24] <_marx_> any one long listing of all files
[14:24] <_marx_> well it's `ls -al`
[14:25] <_marx_> and where are we now?
[14:25] <cjohnston> < doxdrum> Question - is it important the order of the options? -al or -la
[14:25] <_marx_> doxdrum no
[14:26] <_marx_> everyone should be in "/" now.
[14:26] <_marx_> pwd to find out where you are
[14:27] <_marx_> well not seeing responces to where one is in -chat
[14:28] <_marx_> okay let's all go home with `cd`
[14:28] <_marx_> the command `cd ~` will also work
[14:28] <_marx_> now `cd -`
[14:28] <_marx_> and where are we?
[14:29] <_marx_> that was a dash or minus sign
[14:29] <_marx_> yep; "cd -" will take you back to the last directory you were in
[14:30] <_marx_> ok go home
[14:30] <_marx_> and list all files
[14:30] <_marx_> we're gonna shorten up on some of this typing
[14:31] <_marx_> `less .bashrc` will let you view your bashrc file
[14:31] <_marx_> use "q" to quite less
[14:31] <_marx_> we can shorten up on alot of typing by using aliases
[14:32] <_marx_> type `alias` to see what aliases are set now
[14:32] <_marx_> everyone have a output of current aliases?
[14:34] <_marx_> oka to set an alias try "alias 'l=ls -l'"
[14:35] <_marx_> now just type "l"
[14:36] <_marx_> good question hhlp
[14:36] <_marx_> it is not permenamt
[14:36] <_marx_> ow bad spelling
[14:37] <_marx_> to make an alias permenant
[14:37] <_marx_> we need to edit ~/.bashrc; that file we just viewed with less
[14:38] <_marx_> assuming everyone is in there home directories do "nano .bashrc"
[14:39] <Pendulum> < Crewsr3> so when you set up an alias without editing the .bashrc file how long will the alias work?
[14:39] <_marx_> go to the end of the file and add the line "alias 'l=ls -l'"
[14:40] <_marx_> Crewsr3, until you logout of the shell/bash session.
[14:40] <_marx_> 20 minutes to go: how are we on nano w/.bashrc?
[14:41] <_marx_> everyone have that line in .bashrc
[14:41] <_marx_> save and exit the file
[14:41] <_marx_> now bash doesn't know we've changed it's config file
[14:42] <Pendulum> < Yos> how to save and exit ?
[14:42] <_marx_> in nano ctl-x to save and exit
[14:43] <_marx_> so to make bash aware that we've changed it's config file we need to source the config file
[14:43] <_marx_> do that with "source .bashrc"
[14:45] <_marx_> so now you could open a second terminal and "l" should give you the same as "ls -l"
[14:45] <_marx_> well i'm not going to get to everything i wanted to so questions?
[14:46] <_marx_> Question: command to check available disk space
[14:47] <_marx_> i like `df -h` and i usually alias df to that
[14:47] <_marx_> ah info on commands can be found several ways
[14:47] <_marx_> man <command> info <command>
[14:48] <Pendulum> < Jedemco> Question: I don't understand the concept of "alias." What is it and what does it do for me?
[14:48] <_marx_> alias example: `alias 'df=df -h'`
[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
[14:50] <_marx_> for the brave "sudo apt-get install mc"
[14:50] <_marx_> this will install the midnight commander file manager
[14:50] <_marx_> it can also do ftp and sftp
[14:51] <cjohnston> < Yos> Question what is the difference between bash and screen byobu ?
[14:51] <_marx_> screen is like a console or command line window manager
[14:52] <_marx_> screen starts within a bash session
[14:53] <_marx_> anyone install mc?
[14:53] <_marx_> start mc with `mc`
[14:53] <cjohnston> < Jedemco> Question: how do I get to "screen"?
[14:54] <_marx_> Jedemco, just type `screen`
[14:54] <cjohnston> _marx_: is screen installed by default?
[14:54] <_marx_> start mc with `mc`
[14:54] <_marx_> cjohnston, not sure
[14:54] <cjohnston> I believe they would need to install first?
[14:55] <_marx_> we could do 30 minutes on mc probably
[14:55] <cjohnston> 5 minutes left in this session
[14:56] <_marx_> some other command line goodies are lynx for a web browser
[14:56] <_marx_> and alpine for an email client
[14:57] <_marx_> three minutes left thanks everone of coming by today
[14:58] <_marx_> hopefully some of this was helpful