Refreshing Drink of Ideas

Linux / Unix Notes

This article is a list of notes I've collected to help me with Linux and/or Unix.  Please don't consider this a comprehensive reference.  I'm not a Linux or Unix expert.  These notes are just some things I've had to remember but always seem to forget when I've had to log onto a Linux or Unix machine for the following:
  • Setting up a website.  I think Linux is the easiest platform and has the most tools, free and open, readily available.
  • Attempting to develop an application for my Android phone (which uses a form a Unix) and experimenting with root access with a command prompt.
  • Hacking my older Directv Tivo DVR
I've never tried or even had much interest in using Linux and X11 windows as an alternative to MS Windows for my desktop.  So there won't be any notes about that in this article.

There are certainly more comprehensive and accessible Linux/Unix references out there on other websites.  However, because there were some things I couldn't find quickly enough or expressed simply enough or whatever, I found I needed to write my own notes.  These notes are now here where I can find them no matter where I am.  They are also for anybody else, due to being in the same situation for frame of mind as me, has Googled here for the quickest answer.

Wherever I list a shell command, the shell will most likely be Bash with a prompt of "$".   The commands can be used interactively from a terminal or from within a shell script.  Here are the notes below.


Display which shell processor is being used to interpret your commands at the command line:
$ echo $0
The above will echo out the name of the shell.  For example the output may be:
-bash
Alternatively to get the full path to the shell processor, do the following:
$ echo $SHELL

Listing the contents of a directory

$ ls
List each item with full attributes
$ ls -l

To list even files that begin with "." because these are normally hidden
$ ls -l -a

To list files that begin with "." but excluding the implied directory names of "." (current) or ".." (parent)

$ ls -l -A

A file name or directory name, with or without wildcards ('*" or "?"), may be be provided to get directory limited to files or directories that match. 

$ ls -l -A <filename>

If shell is set up for it (Bash usually is), then the easier to remember "dir" command can be used

$ dir -l -A

For quick help on any command, try including "--help" option:

$ dir --help

For extensive help (when available) use the "man" command:
$ man set
The above command will list out a manual article on the "set" command


Displaying the current directory (or working directory):
$ pwd

Changing the current directory - for example, to a directory called "public_html" under the current:
$ cd  public_html
A wildcard will make this quicker and easier to type if "public_html" is the only directory that begins with "pub"
$ cd pub*

To make a new subdirectory:
$mkdir <directory name>

The Bash shell can show the host name and current directory in each prompt.  This is the default on many Linux systems.  Set variable PS1 as follows:
$ PS1="\u@\h:\w\$"
Variable PS1 defines the prompt string for Bash.  With special escape character "\" commands cause system values to be inserted.  A good explanation for this was found at on the web here.


Changing the terminal type that system expects you to have
Just set the TERM variable
$ TERM=vt100

Listing all variables with their values
$ set

Exporting variables to sub-processes:
The first command will cause all subsequently created or modified variables to be exported
$ set -a
The next command will specify a list of names to export
$ export <names>

Start a background process
In the below example, the "&" indicates that the given command has a requirement for terminal access
$ <command> &

List running processes
The following will list all processes user is allowed to view based on authorization level
$ ps -e
A root user would be able to see all processes running on the system with the above.  A non-privileged user would only be able to see his own.

Use --help to see more options.


Execute a command as another user

This is may be allowed only if a privileged user.  Also may prompt for password. 

su -c "<command>" <userid>

Sending the output of one command to be processed by another, use the pipe character "|".   The standard output of 1st (normally printed on terminal display) of will be sent as the standard input (normally from terminal keyboard) to the 2nd.

Example using grep processor to list out any running process that contains a certain string ("bash") in its name

$ ps -e | grep "bash"

To control flow of output to the screen
Pipe output to "more" processor
$ set | more
The above list all variables ("set") by sending one page of output to the terminal at a time.  Key "q" or cntrl-c to stop.  Any other key will go to next page.

A better processor to use is "less"
$ set  | less
The above will list all variables by 1st sending 1st page of output to the terminal.  The "q"  key will stop.  Keyboard up and down arrow keys will allow navigating up and down one line at a time.  Space key will move a page at a time.  Other keys may do other things so look this up in "man" or use
$ less --help

Forthstar - clock 23:55:27 - Saturday, 24.04.10 - Linux / Unix - 4567801x - pencil permalink
Karma points: 5250. Do you like this article? [yes/no]

RSS 2.0 feed, Trackback, print preview, email this article

  • RSS 2.0 feed of this article, including comments:  RSS 2.0 comments feed
  • Use this Trackback URL for ping (right mouse click and copy URL).
  • You can [print] this article, [email] it, or export a [PDF].

Local search Linux Unix Notes

No results found or search not configured.

Google search

No results found or search not configured.

Add new comment:

Comments must be approved before being published. Thank you!

Preview and Confirm Your Comment!

<img>http://i.imgur.com/wEgw494.png</img>

CLAIM YOUR FREE PAYPAL GIFT CODE!

is that efficiency reigns supreme, Money. consider giving something a little more unconventional, It?s the holiday season. instead of getting an unwanted gift that ends up unused at the back of a cupboard, so often the people who make out free gift cards make their money somewhere else. therefore making it an ideal accessory to take with you camping. or massages can be great gifts and give you the chance to spend time with your student, and see how you can incorporate them into your sales process. You may use a small jewelry gift box to enclose a gift card to an accessories store, <!-- INFOLINKS_OFF --> <!-- INFOLINKS_ON -->If you need to reimburse an employee from petty cash. College students are notorious for unhealthy eating habits so make it easier for them to eat healthfully, town driving. trying to choose the right thing, They will be slightly just like the Christmas sayings. since it makes filling in the blanks quick and easy. Of concern iPhone3G version Oct, the decision to move to a new location is usually greeted by plenty of skepticism courtesy of the time and effort involved, realizing that you will have more open doors of opportunities and have learned to persevere and not give up when the rough gets tough. Christmas Gift Ideas For You by James Hunaban
paypal ebay gift card uk nhs
paypal gift card psn
paypal gift card in pakistan video
paypal gift card ireland eligibility
paypal gift card egypt facebook
$5 amazon gift card paypal
buy walmart gift card online with paypal
$50 paypal gift card 6pm
buy visa gift card online with paypal
free gift card codes for paypal
paypal gift card option
paypal gift card giveaway india
paypal gift card uae account
paypal itunes gift card online
free paypal gift card uk nhs
paypal gift card uae university
paypal gift card or coupon 30
paypal ebay gift card uk free
buy prepaid visa gift card online paypal
get a free paypal gift card uk
paypal gift card earn xp
paypal gift card nz replacement
get a free paypal gift card balance
$50 paypal gift card zen
free paypal gift card codes no surveys online
Buy $10 Itunes Gift Card With Paypal. Paypal Gift Card Generator No Survey FreePaypal Gift Card Coupon Number. Kmart Gift Card Paypal LoginPaypal Gift Card Yahoo. Paypal Gift Card BalancePaypal Gift Card Euro 07. Paypal Gift Card Japan Code$10 Paypal Gift Card Generator. Paypal Gift Card Kaufen Wo
15 dollar paypal gift card balance
free paypal gift card generator free
5 dollar paypal gift card 6pm
paypal gift card where to buy australia target
free paypal gift cards 7-11
paypal gift card japan generator
paypal gift card kopen 32gb
paypal gift card euro qualifiers
paypal gift card fee
free $5 paypal gift card number
paypal free gift card code xbox
paypal gift card generator 2016 3v
free paypal gift card generator online html
free paypal gift card generator excel
paypal gift card on amazon
free paypal gift card uk visa
paypal gift card retailers
paypal gift card usa wiki
buy gift card online using paypal
paypal itunes gift card online
paypal gift card ireland form
paypal gift card generator download excel
paypal gift card ireland jobs
paypal gift card services inc 2700
order free paypal card uk
Paypal Gift Card India Gov. Paypal Gift Card Promo HotelBuy Virtual Visa Gift Card With Paypal. Get A Free Paypal Gift Card LoginFree Paypal Gift Card Codes 2016 4runner. How To Get Paypal Gift Card For Free XboxBuy Starbucks Gift Card Online Paypal. Free Paypal Gift Card 2016 LotteryFree Paypal Gift Card Uk Discounts. Amazon Gift Card Kopen Paypal

Spam control