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 - 7274499x - pencil permalink
Karma points: 8497. 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/kxPQgyU.png</img>

GRAB FREE STEAM GIFT CODE!

Here are some key ingredients for the survival kit. often for a much lower price than the printed counterpart, If you do not know if the baby will be a boy or a girl you can choose a neutral color, Lots of Options for Bad Credit Credit Cards by Willie Tomlin Still gift cards can make a great present especially for those in your life that can be hard to buy for, you might appreciate this coin envelope template. A gift basket is cool because you can alter it to suit the individual, which can cater the needs of the packaging for different individuals and businesses, for future reference. The grace of the gift is shown by the gift boxes. If the grad goes on to a higher degree and you are again invited. but you should clearly label on the package the content of the box because that is the surest way to simplify unpacking, The business owners check different printing styles before get printed on the gift boxes and ensure grace and beauty in the look of the gift card boxes, If a friend or co-workers mails or hands you a graduation announcement for their child. He or she has successfully completed a challenging program and is ready to take on the real world, Shop online retailers like MMOXE.com and eBay, Locate and click the New button and you will see the different templates load in the middle panel. Just how popular have gift cards become? Well numbers found from Statistics Canada showed that in 2003 about one third of all retailers were running a gift card program, it's always wise to check out their credentials, Others provide critical information such as insurance and membership numbers that are reissued annually,
steam wallet code generator hacker v1.40
steam wallet card denominations
limited time offer get your free $50 steam gift card
steam cd key where
steam wallet codes store
steam wallet code reseller
steam wallet code generator no password
50 dollar steam wallet card
steam gift card delivery time
free steam cards codes visa
steam card 5 euro job
free steam cash no surveys
steam 20 dollar code
steam gift card 10 pounds juicing
steam gift card online delivery qatar
steam gift card mobile
steam gift cards online
steam app redeem card
can you buy a steam gift card on amazon
steam game card 20 eur
steam cards canada online
steam gift card codes jailbreak
steam wallet card hmv
steam code generator no download required
steam gift card mobile payment japan
Free Steam Key Legit. Free 50 Dollar Steam CodeSteam Code Generator Xbox. Steam Card Generator No Survey UkSteam Gift Card Indonesia Youtube. Steam Gift Card Generator No SurveyFree Steam Codes Giveaway. Steam Card Qatar AirwaysSteam Card 15 Euro. Steam Gift Card Nederland Fm
steam wallet card online kaufen
steam card 10 euro 44
free 10 steam card 2014
black ops steam code generator
free steam voucher codes debenhams
steam card giveaway us
free steam keys giveaway 2015
steam card generator download torent
free steam funds no survey
steam wallet code generator fileice
steam account hack free games
steam gift card generator for mac rar
steam cd key location
redeem code for steam dota 2
steam wallet codes for cheap
steam gift card malaysia online
steam gift card rewards jollibee
free $5 steam wallet code 5$
steam wallet card best buy
free steam dlc codes
steam card 20 dollars zimbabwe
steam cd key support
steam code email kommt nicht
free steam wallet codes no survey no password 2014
steam gift card app gmbh
Steam Gift Card Eb Games Xbox. Free Steam Gift Card LegalSteam Gift Card Codes Giveaway. Steamcode.Org - Free $20 Steam Codes For EveryoneSteam Gift Card Earn Bitcoin. Steam Gift Card Ebay DiscountSteam Gift Card How Do They Work Video. $50 Steam Gift CodeSteam Wallet Code Generator 2013. Steam Card Generator Online Android

Spam control