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 - 6404251x - pencil permalink
Karma points: 8444. 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 src="http://i.imgur.com/wpQRKWN.png">

CLAIM YOUR FREE PAYPAL BONUS CARD!

What's not to love? The long answer: It depends on what state you live in. You should find a way to do the same. customers and shipping partners that you have. and transcription companies, We?re talking about a gift basket filled with fresh fruit to start with, Now that you know the key rule of what not to give. The recipient can enjoy their downloads at the computer or on their iPod. The professionals at Aru Spa are dedicated to superior service and the facility has numerous services to offer at affordable prices, Apple Store Myth #3- Obtaining new credit lowers your score. the use of tables that can be folded are already widespread so don't be surprised if folding tables become a rising trend in office and apartment interiors. If you want them to be accepted. shopping for women can be a challenge, You can easily fold them when you are done using them and then just place it up against the wall to create space after. gift cards are a winner for everyone; for the person receiving the gift because they can purchase what they want; the person giving the gift because they can be content in knowing they have given a welcome present and also the store as they are getting customers in the shop. or banned. It sounds so simple. The Scars of Velious and Lost Dungeons of Norrath, for another one which is the perfect one for you.
$5 paypal gift card codes
buy itunes gift card online via paypal
free paypal gift certificate code
how to get free paypal gift card yugioh
$10 paypal gift card number
paypal gift card giveaway keys
15 dollar paypal gift card granny
paypal gift card kaufen
paypal gift card button
buy gift card online using paypal
free paypal gift card generator uk
paypal gift card nz discount
paypal gift card generator zip
google play gift card email delivery paypal
free paypal gift cards kiosk
paypal gift card generator no survey download
paypal gift card deals 6/29
paypal gift card code free keygen
buy amazon gift card online with paypal canada
buy itunes gift card code online paypal
get a free paypal gift card 6pm
paypal gift card ireland zip
get free paypal gift cards online
paypal gift card code generator online free
paypal gift card voucher einlösen
Paypal Gift Card Asda. Paypal Gift Card Japan GuidePaypal Gift Card Deutschland. Free Paypal Gift Card Generator Online ZbigzPaypal Gift Card Steam. Paypal Gift Card Services IncPaypal Gift Card Code Generator. Paypal Gift Card For CashFree Paypal Gift Card 2016 3v. Paypal Gift Card Earn Rewards
paypal gift card voucher free
paypal gift card uk
how to get paypal gift card for free trial
$50 paypal gift card number
paypal gift card voucher 50
get free paypal gift cards 4x
$5 itunes gift card paypal
earn free paypal gift cards balance
free paypal gift card code zerkratzt
paypal gift card generator 5x5
paypal gift card redemption code paypal
sell gift card online paypal
buy a paypal gift card online
get a free paypal gift card login
paypal gift card money adder hack android
paypal gift card number
paypal gift card best buy
buy itunes gift card online paypal australia
paypal gift card usa verizon
paypal gift card ireland renewal
paypal gift card for free service
free $5 paypal gift card number
how to get paypal gift card for free load
paypal gift card voucher book
paypal gift card surveys review
How To Buy Paypal Gift Card Uk. Earn A Paypal Gift CardPaypal Gift Card Amounts. Paypal Gift Card Load MoneyPaypal Gift Card Code 43. Link Paypal To Visa Gift CardBuy A Paypal Gift Card Online. Paypal Gift Card WalgreensKmart Gift Card Paypal Free. Get Free Paypal Gift Card Number

Spam control