Command Line Basics Part 2

Session Logs

   1 [19:58] <_marx_> i'm going to refill my mug before the next session starts, brb < 1 minute
   2 [20:01] <_marx_> who else is lazy?
   3 [20:01] <_marx_> my picture is in Websters beside lazy
   4 [20:02] <_marx_> so typing ls -alh is too much sometimes
   5 [20:02] <_marx_> yeah i'm that lazy ;)
   6 [20:03] <_marx_> bash has a handy feature called aliases
   7 [20:04] <_marx_> to see what aliases you have now do 'alias'
   8 [20:04] <_marx_> this will output all your aliases
   9 [20:05] <_marx_> mine looks like this...
  10 [20:05] <_marx_> mark@spinach:~$ alias
  11 [20:05] <_marx_> alias ..='cd ..'
  12 [20:05] <_marx_> alias a='ls -a'
  13 [20:05] <_marx_> alias l='ls'
  14 [20:05] <_marx_> alias la='ls -alh'
  15 [20:05] <_marx_> alias ll='ls -lh'
  16 [20:05] <_marx_> alias ls='ls --color=auto'
  17 [20:05] <_marx_> alias ping='ping -c5'
  18 [20:05] <_marx_> alias sagud='sudo apt-get update'
  19 [20:05] <_marx_> the last one i'd forgotten about
  20 [20:06] <_marx_> and those have been customized so they won't be what you'll get on a stock installation
  21 [20:07] <_marx_> creating an alias is easy
  22 [20:08] <_marx_> df is a handy command (disk free); it shows the available space on your hard drive(s)
  23 [20:08] <_marx_> but it's output isn't very Human readable
  24 [20:09] <_marx_> so df -h makes nicer output
  25 [20:09] <_marx_> to create an alias for this do 'alias df='df -h''
  26 [20:10] <_marx_> now this alias will NOT be there when you log in again
  27 [20:10] <_marx_> or just open another terminal and it won't work
  28 [20:12] <_marx_> to make it persistent we have to edit our .bashrc file
  29 [20:12] <_marx_> again this is just one way
  30 [20:12] <_marx_> some distros have a .bash_aliases file
  31 [20:13] <_marx_> go home (cd)
  32 [20:13] <_marx_> and let's edit .bashrc
  33 [20:13] <_marx_> open it with an editor, preferably a cli editor since this is command line basics
  34 [20:14] <_marx_> example from /home/you 'vim .bashrc'
  35 [20:16] <_marx_> move down the file with the arrow keys to the alias section
  36 [20:16] <_marx_> in vim pres "i" to enter insert mode
  37 [20:17] <_marx_> add alias df='df -h'
  38 [20:17] <_marx_> press esc (escape key) to exit insert mode
  39 [20:17] <_marx_> then :wq or :x to save and quit
  40 [20:18] <_marx_> now open a new terminal and try the df command
  41 [20:19] <_marx_> hum my example doesn't include source...
  42 [20:20] <_marx_> if you add an alias to ~/.bashrc bash will not know about the new alias until you login again or source ~/.bashrc
  43 [20:21] <_marx_> sourcing that file is done by 'source ~/.bashrc'
  44 [20:22] <_marx_> okay where am i...
  45 [20:22] <_marx_> file manager for command line only environment
  46 [20:23] <_marx_> midnight commander rocks for this task
  47 [20:23] <_marx_> it is not installed by default
  48 [20:23] <_marx_> so to give it a test run we'll need to install it
  49 [20:24] <_marx_> the package name is mc so 'sudo apt-get install mc'
  50 [20:25] <_marx_> okay that was long enough for me to install it from a rather fast mirror
  51 [20:26] <ClassBot> libssd asked: Docs for Terminal Enhancements?
  52 [20:26] <_marx_> no clue libssd
  53 [20:26] <ClassBot> libssd asked: Re Terminal Enhancements. After sudo su, I should be root, but still get "You need to be root before going on"
  54 [20:26] <_marx_> what the heck if you don't know you don't know
  55 [20:27] <_marx_> again i'm not sure libssd I'd guess you need to set roots password
  56 [20:27] <_marx_> that is a guess as i'm not familiar with terminal enhancements
  57 [20:29] <_marx_> to start midnight commander just type 'mc'
  58 [20:30] <_marx_> mc uses the function keys to do various tasks
  59 [20:31] <_marx_> F4 will open and editor
  60 [20:31] <_marx_> the up and down arrow keys work as expected, moving up and down the list of files and directories
  61 [20:32] <_marx_> left and right arrow keys a little different, they will move you up and down the directory structure
  62 [20:33] <_marx_> so if we move down to that directory we made last hour "stuff"
  63 [20:34] <_marx_> when it's highlighted the right arrow key will enter that directory
  64 [20:34] <_marx_> <libeviltux-dev> QUESTION: How do you rename a file without MC?
  65 [20:35] <_marx_> mv (move) will rename a file
  66 [20:35] <_marx_> in mc F6 will open a dialog to rename/move a file
  67 [20:36] <_marx_> Questions?
  68 [20:40] <_marx_> should note here that mc can do sftp and ftp as well
  69 [20:40] <_marx_> although i seldom use that feature
  70 === tagpaul is now known as paultag
  71 [20:42] <_marx_> okay how about a command line web browser
  72 [20:42] <_marx_> two come to mind lynx and links
  73 [20:42] <_marx_> i believe lynx is the older of those two
  74 [20:43] <_marx_> so let's try that one; 'sudo apt-get install lynx'
  75 [20:45] <_marx_> QUESTION: Any other way to play a file beside aplay?
  76 [20:46] <_marx_> oh many...but my old brain
  77 [20:48] <_marx_> mplayer is one...
  78 [20:48] <_marx_> sox another
  79 [20:50] <ClassBot> There are are 10 minutes remaining in the current session.
  80 [20:50] <_marx_> Questions? I'm out of script ask away yall
  81 [20:52] <_marx_> There is a survey for todays event at http://www.surveymonkey.com/s/FJ697T7
  82 [20:53] <_marx_> please take a few minutes to give us your feedback

UserDays/07102010/Command Line Basics Part 2 (last edited 2010-07-10 20:07:38 by alderaan)