Linux


Linux is a very capable and stable OS, a good replacement for Windows (Bionicpup, Xenialpup, TahrPup, SlackoPup). Linux is not for the casual user but those that spend the time learning it will find it able to do everything you want it to do. Linux with Apache makes a super reliable server and at no cost.

32bit vs 64bit Linux: 32bit Linux runs very well on 32bit and 64bit hardware. What this means is you can set up your favorite 32bit Linux on a flash drive and use it on any hardware.

Unfortunately, 32bit web browsers are no longer well supported. This means you will have problems with Google/Youtube websites which use non-standard Javascript on 32Bit hardware. If you need an updated 32bit browser:

Download updated Palemoon Portable Win32bit
Download updated Palemoon Portable Nix32bit

Fossapup is your best bet for newer laptops. However, I have had much difficulty getting WiFi and mouse to work on newer HP and Lenovo laptops. Booting requires tweaking bios settings to enable legacy USB boot and pressing esc to bring up boot menu. Also, newer thin laptops lack ethernet ports, beware. Disappointing that Fossa kernal cannot find newer WiFi hardware. Shame really, nice hardware.

Puppy LINUX does not need to be installed on your hard drive. You can run Puppy Linux directly from a CD (often called a live CD) or create a folder and copy the contents of the ISO or CD to that folder. Grub4Dos is utility included with Puppy that creates a menu allowing you to choose which OS to run. Grubdos can be run right off the live CD created from a downloaded Puppy ISO.

If your laptop runs XP/Vista/7/8/10, it will probably run Puppy Linux from a live CD and from USB flash drive. If you want your USB flash drive to work like a live CD (no saved sessions) then don't save a session when prompted. Puppy installed on a USB flash drive can be run on different manufacturers hardware providing a portable OS that you can customize to meet your needs. I am running Tahrpup on my 2004 Dell laptop daily using my DOS and Windows compilers and Utilities.

Using Wine utility you can run Win 95/98/XP/Vista/8.x/10 programs such as:

   BRU(Bulk Rename Utility), ColorPic, NexusFile, RichCopy, Tree, Unstopable
   BREXX, OOREXX, Regina REXX, ROO, R4, PowerBASIC, FreeBASIC, PowerShell
   DocReader, GVIM, JellyFish, MobiPocket(DRM too), Notepad, Notepad++, SPFPRO, SPFSE, SPF365, TextPad
   MS Office 97, MS Works, PAF, AncestralQuest
   Winamp, WinRAR, PKZIP, Webreaper, TCC
   
Not every Windows program works in Wine but many do and you have full access to the Linux directory/file structure.
Note: Wine can invoike DOSBOX(if installed) and run a DOS program (say via a .bat program)
Tip: When WINE is fully installed, open a console and type CMD. This will invoke the WINE console within the terminal or use wineconsole. This works as WINE Windows programs are actually LINUX programs.

Installing Wine on 64bit:

   1.  Download 32bit compatibility SFS using quick pet (Useful).
   2.  Load 32bit compatibility SFS using SFS-Load-on-the-fly (menu/setup)
   3.  Open console, type LDCONFIG then close the console.
   4.  Download/Install Wine using quick pet (Useful or Office).
   5.  Open console, type wine winecfg.
   6.  Click yes to download the mono and gecko packages as prompted.

   Once wine is installed:
   1.  Open console and type regedit or open wineconsole (root/.wine/drive_c/windows/system32).
   2.  Find environment settings (HKEY_LOCAL_MACHINE/System/CurrentControlSet/Control/Session Manager/Environment).
       or search for C:\windows\system32\wbem (case is important).
   3.  Add environment variables as needed by your windows software.
   4.  Append path to your windows batch files pointing to your software to PATH.
Note that all wine programs are found in directory shown in step 1. I like to have wineconsole on my desktop and have batch files in a directory to execute my windows programming utilties with the PATH environment variable pointing to that folder.

Wine will allow XP cmd.exe (not win7 cmd.exe) to run in the wineconsole which makes your programs run much better. Plus you can use some of XP's utilites such as ftp and ping. There is an exmaple below showing you how to use a simple sh script to invoke wincosole then run XP's cmd.exe then your program.

Using DOSBox and DOSEmu you can run your MSDOS based programs/games (single and multiplayer using ipx). DOSBox runs MSDOS programs that do not use fancy memory tricks. Runs on 64bit Linux.

Both DOSBox(very solid) and DOSEmu work very well with Tahrpup and Slackopup providing a real-time MSDOS environment with full access to LINUX file/folders:

  4DOS,
  ARC/ARJ/DCF/JAR/LZH/PAK/PGP/RAR/TAR/UU/ZIP/ZOO,
  BASICA, GWBASIC, PowerBASIC(DOS), QBASIC, TurboBASIC, ZBASIC(4.7),
  MS COBOL/FORTRAN/PASCAL, MFCOBOL,
  Borland C, Microsoft/Quick C, Turbo C, PowerC,
  Breeze, Brief, DOSEdit, E, E2, MIX, MultiEdit, SPF/PC(1-4) Tritus SPF, MS-DOS Editor, VIM,
  Co-Dir, Maxdir, NDir, ZanyDir,
  Micro Mapper, POPDOS,
  Quiksort, Simdoc, BATCOM, BAT2EXEC,
  BREXX, PCDOS REXX, Personal REXX, Regina REXX, REXX88,
  Think of DOSEmu and DOSBOX as MSDOS Consoles for Linux which means you can use millions of MSDOS programs.
  Best of all, Xenialpup/Tahrpup/Slackopup Linux OS's run lightening fast on XP laptops.

Sample AUTOEXEC.BAT for DOSemu


     @ECHO OFF
     rem autoexec.bat for DOSEMU + FreeDOS
     path z:\bin;z:\gnu;z:\dosemu
     set HELPPATH=z:\help
     set TEMP=c:\tmp
     blaster
     prompt $P$G
     unix -s DOSDRIVE_D
     if "%DOSDRIVE_D%" == "" goto nodrived
     lredir del d: > nul
     lredir d: linux\fs%DOSDRIVE_D%
     :nodrived

     rem uncomment to load another bitmap font
     rem loadhi display con=(vga,437,2)
     rem mode con codepage prepare=((850) z:\cpi\ega.cpx)
     rem mode con codepage select 850
     rem chcp 850
     lredir e: linux\fs/media/cdrom c
     unix -s DOSEMU_VERSION
     echo "Welcome to dosemu %DOSEMU_VERSION%!"
     unix -e
     REM C: = /root/.dosemu/drive_c
     REM D: = PUPPY ~
     REM E: = PUPPY SUPER ROOT
     REM F: = PUPPY /mnt/home
     REM Z: = dosemu & FREEDOS
     REM --- Setup My Pathing ---
     lredir F: linux\fs\mnt\home
     SET DRV=F:
     SET PATH=%PATH%;%DRV%\U\B;%DRV%\U;%DRV%\U\PCDOS
     REM --- Link F: to C: ---
     ASSIGN C=F
With Puppy Linux How do I get these to run?:
  BRU DOSBox DOSEmu Network Drives Network Printer Icons Winamp NexusFile PAF SPF SSH CMDS

  MobileLite Count Files

    MobileLite by Kinston
      Turn MobileLite on making sure WiFi light is on.
      To enter MobileLite Server:
      1.  Open Web Browser
      2.  In address bar type  192.168.200.254
          Browser should open to MobileLite Page.  Note gear symbol
          below address bar allows access to configuration.
      To play music or video files;
      Either:
          Connect to MobileLite via USB Cable
          1. Click on drive icon that appears (wait a while)
          2. Use File manager to select folder/files and play.
        OR
          Connect to MobileLite via WiFi
          1.  Run YASSAM Samba Share Search to find USB@MOBILELITE
          2.  Use File manager to select folder/files and play.

    Wine - Adding to Default Path
     Wine Pathing
      1.  Download/Install Wine.
      2.  Using file manager (ROX) go to root.
      3.  Click on icon to display hidden files/folders.
      4.  Click on .wine folder.
      5.  Open system.reg in Geany.
      6.  Find "PATH"=str(2):"C:\\windows\\system32;
      7.  Add new path to end of line.
          C:\\windows\\system32;C:\\windows;C:\\windows\\system32\\wbem;z:\\mnt\\home\\u\\bwine;

          Alternate method, open Wineconsole and run regutil searching for \system32\webm, add desired
          path to end of reg entry.

          Reliable method, open Wineconsole and run regutil:
            HKEY_LOCAL_MACHINE, CURRENTCONTROLSET, CONTROL, SESSION MANAGER, ENVIRONMENT
            add desired path to beginning or end of the PATH entry. Image of registry


    Wine - Run a Windows (XP/311) Program from Wine Console
     Wine Start
      1.  From within the Wineconsole, START "Z:\mnt\home\u\spfpro\spfpro.exe"
          This will open execute the windows program.

      Or even better using this script saved to the desktop:

     #!/bin/sh
     # Runs SPFPRO
     wineconsole \\mnt\\home\\u\\bwine\\cmd.exe /K start \\mnt\\home\\u\\e\\spfpro\\spfpro.exe

     #!/bin/sh
     # Runs SPFSE365
     wineconsole \\mnt\\home\\u\\bwine\\cmd.exe /K start \\mnt\\home\\u\\e\\spfse365\\graphic\\bin\\spf80ge.exe

     As you can see, the script can be adapted to any windows program.  Note that only the XP cmd.exe command processor
     will run in the wineconsole.  Win7/10 cmd.exe will not run in wineconsole.  I keep a copy of XP cmd.exe in
     the bwine folder where I keep other winxp utilities and batch files to call them.   The script calls wineconsole
     passing it the location of the winxp command program and the /K parm which tells winxp to execute the following program
     and stay open.

     After the script is created, copy the script to the desktop.  You can now execute your windows program directly
     from the Linux desktop without first calling up the wineconsole.  You can also change the icon by right-clicking
     on the generic script icon, select file, then select set icon.  You can then drag an icon to the box which will change
     it to your favorite icon.

     Your windows program will run much better under XP cmd.exe than the supplied wineconsole cmd.exe.  I keep my XP
     utilities in the bwine folder which I add to the windows registry path.

     Download some useful XP Utilities

    OOREXX - Under Wine
     OOREXX with Wine
      1.  Install Wine Package.
      2.  Download OOREXX for Windows 32bit.  Download
      3.  Open wineconsole.         /root/.wine/drive_c/windows/system32/wineconsole.exe
          Note that once you find wineconsole in ROX filer you can drag it to the
          desktop and just click on it and of course change its icon.  Wineconsole
          is essentially a 32 command line box (console) that can run win32 applications
          within the box or in a separate box using the START command.
      4.  Enter:  z:    and then cd \root\downloads
      5.  Install OOREXX into Wine by typing oorexx-4.2.0.windows.x86_32.exe
          OOREXX will install itself in   /root/.wine/drive_c/Program Files/ooRexx
          folder, add ooRexx folder to Wine PATh variable and define rex as an executable
          extension in Wine system.reg file.
      6.  To execute a REXX program:
          a.  Execute wineconsole

    BRU - Bulk Rename Utility
     BRU
      1.  Download/Install Wine and Winetricks.
      2.  Download Bulk Rename Utility.
      3.  Install as normal.  If already installed on a Windows system just copy to Linux folder and
          click on Bulk Rename Utility.exe .

    
      WDTVLive
      Connect to WDTVLive through network/Wifi router and access attached hard drive.
      1.  Plug hard drive or flash drive into WDTVLive box.
      2.  Click on Puppy Menu.
      3.  Select Network.
      4.  Select YASSM Samba Search.
          When search is complete;
            select the Hardrivename@WDTVLive.
            Press the mount button.
            ROX Filer will open showing the root of the hard drive.

    Winamp
      1. Download/Install Wine and Winetricks.
      2. Download Winamp (I use 2.76 as it is a solid performer).
      3. Find the Winamp.exe installed under the .wine folder
         (/root/.wine/drive_c/Program Files/Winamp/winamp.exe). Drag the
         winamp.exe to the desktop.
      4. Run Winamp. Do NOT move the player window.
      5. Right click on the Winamp task (at bottom of screen) and choose stick.
         Now you can drag the player anywhere you want and the menu will work.
         To bring up the Winamp menu, don't use the sinewave graphic (top left), instead
         click on blank area of player after the kHz.  Menu will display properly from
         there.  Ok it's not perfect but it plays folders including super folders on
         mounted network drives and sounds great!  Winamp,Queen and Skull Candy Buds Rock!
         Winamp 2.76 will also run on 32Bit Win10 as will most XP programs.

    NexusFile
      1.  Download/Install Wine and Winetricks.
      2.  Download NexusFile portable version.  Everything works including ftpclient.

    PAF5
      1. Download/Install Wine and Winetricks.
      2. Copy PAF5 folder to Linux or Install using PAF5EnglishSetup.exe.
      3. Use Linux file manager (ROX) to select PAF5.exe.  See below to create desktop icon.
      If installed using the PAF5 install program it will install in the /root/.wine/Program Files/FamilySearch folder.
      Remember that any folder with . before the name is a hidden folder in ROX file manager.
      When printing a chart, you print to a pdf, open the pdf and then print to your printer installed using CUPS.

    SPFPro/SPFSE
      SPFPRO, SPFSE and SPFSE365 by Tim Tetiva run just fine in Wine.  See above example of calling the
      program from an sh script which can be placed on the desktop.  SPF works best when run under XP cmd.exe.
      This includes SPFSE365 which normally would not run on XP.

      1. Download/Install Wine and Winetricks.
      2. Copy the SPFPro or SPFSE folder from Windows to the /root folder.
      3. Use Linux file manager (ROX) to select Spfpro.exe in the SPFPRO folder.
    Wine will automatically wrap and run the program. Wine will provide access to the Linux OS super root
    folder as drive letter Z.  Mounted USB flash drives, harddrives, network shares should appear in
    the /mnt folder as a sub folder.

    This also works for SPF/SE and SPF/365.

    Will SPF/PC 4.0/3.0/2.1 run on Linux?  Yes using DOSBox or DOSEmu.  However, the DOS
    versions of SPF do not support lower-case filenames or filenames that do not conform to the 8.3 naming standard.
    Saving a file that has a lower-case letters will cause it to be converted to upper-case.

    DOSBox
      1. Download/Install DOSBox.
      2. Find DOSBox in Menu under Utility (Tahrpup) and run once.
      3. Using ROX file manager, enable viewing hidden files (click on the eye).
      4. Select  /root/.dosbox/dosbox-0.74.conf (DOSBox config file) which should load in Geany.
      5. Find/Change fullresolution=1024x768 (1366/768 or what puppy setup reports) and output=overlay
         which will give best look in full screen.
      6. Change autolock=true to autolock=false (keeps mouse from being trapped in DOSBox).
      7. Find ipx=false and change to true if you want to play multiplayer games.
      8. Find [autoexec] section (very bottom) and mount the Linux home folder:

         @echo off
         mount L /
         mount C /mnt/home
         SET DRV=C:
         SET PATH=%PATH%;%DRV%\U\B;%DRV%\U\REXX\PCDOS;%DRV%\U
         C:

    Now when you run DOSBox, it will have full access to any folders and files.  Create a folder to keep
    MSDOS programs, batch files, editors etc. just like you would under MSDOS/PCDOS.

    To give DOSBox access to all of Linux:
         mount L /

    If you want to use your MSDOS REXX, editors, etc. on Linux, just run them under DOSBox.

    DOSEmu
      1.  Download/Install DOSEmu. (Tahrpup package manager, Slackopup here).
      2.  Run DOSEmu from Menu/Utilty.
      3.  Type edit autoexec.bat (and be pleasantly surpirzed as an old friend appears).
      4.  Scroll to bottom of autoexec.bat file and add:
          lredir F: linux\fs\mnt\home
          and path statements to your DOS stuff...
            SET DRV=C
            SET PATH=%PATH%;%DRV%:\U\B;%DRV%:\U;%DRV%:\U\PCDOS
          which for me provides access to all my DOS utilities, SPF, REXX, Compilers, etc..

    ICON
      1. Use ROX file manager to find /usr/share/applications .
      2. Left-click and drag dosbox.desktop file to the desktop.
    The short cut is now on the desktop.  To change the name right-click and select
    edit item.

    Network Drive Access
    How do I get access to a network drive(NAS)?  Here is one way:
      1. Open terminal/shell program (think windows CMD or COMMAND).
      2. Make a folder in the /mnt folder through which the network drive is accessed.
         mkdir /mnt/mycloud
      3. Enter the following:
         For annonymous user:  mount -t cifs //wdmycloud/public  /mnt/mycloud
             When prompted for password, press Enter.
         When userid and password are required:  mount -t cifs //wdmycloud/public  /mnt/mycloud username name
             Enter password when prompted and press Enter.
         Using IPA:  mount -t cifs //192.168.1.20/public   /mnt/mycloud

    Files/folders on the network drive are accessable in the /mnt/mycloud folder.
    The Linux file manager can be used to copy to/from and delete files from the
    network drive.  Tahrpup comes with VLC so when you click on your mp4 file it
    will play automatically.

    Network Printer
    How do I print to a Network Printer?
      1.  Use CUPS to manage printer.
      2.  Select Add Printer.
      3.  Select http protocal.
      4.  Enter the IPA of the printer such as http://192.168.9.108
      5.  Select printer brand such as Brother.
      6.  Select the closest printer model.
      Application will then have printer as choice.

    SSH Connection to your Linux Server
    How do I use the Linux console to connect to my Linux web server?
      1.  Run console program.
      2.  Type  ssh userid@IPA      (server IPA) and press ENTER.
      3.  Enter password when prompted.

      You can now do everything you used to in Putty under windows.

    Count files in Subdirectories
    How to count files in Subdirectories:
      1.  Run console program
      2.  Enter: find myfolder -type f | wc -l
      Result of count will be displayed.  May take a minute or two.

    Linux Commands
    
  Moving Around the Filesystem
Commands for moving around the filesystem include the following: pwd: The pwd command allows you to know the directory in which you're located (pwd stands for "print working directory"). For example, pwd in the desktop directory will show ~/Desktop. Note that the GNOME terminal also displays this information in the title bar of its window. cd: The cd command allows you to change directories. When you open a terminal, you will be in your home directory. To move around the filesystem, use cd. To navigate to your home folder, use cd ~ To navigate to your desktop directory, use cd ~/Desktop To navigate into the root directory, use cd / To navigate to your home directory, use cd To navigate up one directory level, use cd .. To navigate to the previous directory (or back), use cd - To navigate through multiple levels of directories at once, use cd /var/www, for example, which will take you directly to the /www subdirectory of /var. Manipulating Files and Folders You can manipulate files and folders by using the following commands. cp: The cp command makes a copy of a file for you. For example, cp file foo makes an exact copy of the file whose name you entered and names the copy foo, but the first file will still exist with its original name. After you use mv, the original file no longer exists, but after you use cp, that file stays and a new copy is made. cp /oldpath/file.ext /newpath/destfile.ext Copy filename.ext to destfilename.ext cp ~/oldpath/file.ext ~/newpath/file.ext ~ starts pathing in home folder cp -b /oldpath/file.exe /newpath/file.ext Force backup of like named file in /newpath cp --backup=numbered ~oldpath/file.ext ~/newpath/file.ext Numbers backup .~1~ ~2~ etc cp -i /oldpath/file /newpath/file Prompt before overwrite cp -u /path/file /newpath/file Copy file(s) only if newer cp /path/*.* /newpath Copy all to newpath cp -R /oldpaths /newpath Copy all files/folders from oldpath to newpath mv: The mv command moves a file to a different location or renames a file. Examples are as follows: mv file foo renames the original file to foo. mv foo ~/Desktop moves the file foo to your desktop directory but does not rename it. You must specify a new filename to rename a file. mv file.ext newfile.ext Move (rename) file.ext to newfile.ext mv folder newfolder mv -i Prompt before moving mv -u Move only file(s) that do not exist in destination folder To save on typing, you can substitute ~ in place of the home directory. Note: If you are using mv with sudo, you will not be able to use the ~ shortcut. Instead, you will have to use the full pathnames to your files. rm: Use this command to remove or delete a file in your directory. It does not work on directories that contain files. rm /path/file.ext Remove (delete) file rm file1 file2 file3 Remove multiple files rm *.ext *.* rm -i /path/file rm -i *.ext Prompt before removal rm -d folder Remove folder only if empty rm -f /path/file Remove file without error message rm -r /path rm -R rm --recursive Remove all files/folders ls: The ls command shows you the files in your current directory. Used with certain options, it lets you see file sizes, when files where created, and file permissions. For example, ls ~ shows you the files that are in your home directory. ls /mnt/home ls ~ ls -a ls -all Show all ls -A ls --almost-all ls -B ls -ignore-backups ls --color=never ls -l Detailed output ls -g ] Omit the owner ls -o Omit group details ls-l --author Output more info ls -l -h ls-l --human-readable ls -l -s Human readable sizes ls -R /home Show files/folders downward ls -l -n Physical user id and group ids ls -X ls --format=across Show in columns ls -m ls --format=horizontal ls -1 ls --format=single-column ls -c ls --format=vertical One file/folder per line ls --sort=none ls -U No sort ls --sort=size ls -S Sort by size ls --sort=time ls -t Sort by time ls --sort=version ls -v Sort by version ls -r --sort=size ls --reverse --sort=size Sort by size in reverse order ls -ldi folder Display Inode number Use man ls to read Linux manual. mkdir: The mkdir command allows you to create directories. For example, mkdir music creates a music directory. chmod: The chmod command changes the permissions on the files listed. Permissions are based on a fairly simple model. You can set permissions for user, group, and world, and you can set whether each can read, write, and/or execute the file. For example, if a file had permission to allow everybody to read but only the user could write, the permissions would read rwxr--r--. To add or remove a permission, you append a + or a - in front of the specific permission. For example, to add the capability for the group to edit in the previous example, you could type chmod g+x file. chown: The chown command allows the user to change the user and group ownerships of a file. For example, chown jim file changes the ownership of the file to Jim. UU uuencode: The uuencode command uses the syntax: uuencode original_filename final_filename > encoded_filename Replace original_filename with the name of your binary file. Replace final_filename with the name that you want the file to have when it is eventually decoded (usually the same as original_filename). Replace encoded_filename with the name you want to give the uuencoded version of the binary as it will appear in your directory. For example, to convert a binary file named myfile.zip into a uuencoded (text) file named myfile.uue, you would enter at the Linux prompt: uuencode myfile.zip myfile.zip > myfile.uue The original binary file myfile.zip is unchanged, and the uuencoded file myfile.uue is now located in your current directory. The greater-than character (>) is used to redirect output; it takes the output of the uuencode command and directs it into the file myfile.uue (rather than onto your screen). The purpose of the uuencode program is to translate a binary file that contains unprintable (non-text) characters into a format that is entirely readable. This prevents mail, news, and terminal programs from misinterpreting non-text characters as special instructions. A text file produced by uuencode may thus be mailed as an ordinary mail message and later uudecoded into its original binary form by the recipient. The uuencoded file is usually larger than the original binary file, because the unprintable characters in the binary file are expanded into multiple readable characters. uudecode: The uudecode command uses the syntax: uudecode myfile.uue System Information Commands System information commands include the following. df: The df command displays filesystem disk space usage for all partitions. The command df-h is probably the most useful. It uses megabytes (M) and gigabytes (G) instead of blocks to report. (-h means "human-readable.") free: The free command displays the amount of free and used memory in the system. For example, free -m gives the information using megabytes, which is probably most useful for current computers. top: The top command displays information on your Linux system, running processes, and system resources, including the CPU, RAM, swap usage, and total number of tasks being run. To exit top, press Q. uname -a: The uname command with the -a option prints all system information, including machine name, kernel name, version, and a few other details. This command is most useful for checking which kernel you're using. lsb_release -a: The lsb_release command with the -a option prints version information for the Linux release you're running. For example: user@computer:~$ lsb_release -a LSB Version: n/a Distributor ID: Ubuntu Description: Ubuntu (The Breezy Badger Release) Release: Codename: breezy ifconfig: This reports on your system's network interfaces. iwconfig: The iwconfig command shows you any wireless network adapters and the wireless-specific information from them, such as speed and network connected. ps: The ps command allows you to view all the processes running on the machine. The following commands list the hardware on your computer, either of a specific type or with a specific method. They are most useful for debugging when a piece of hardware does not function correctly. lspci: The lspci command lists all PCI buses and devices connected to them. This commonly includes network cards and sound cards. Lsusb: The lsusb command lists all USB buses and any connected USB devices, such as printers and thumb drives. lshal: The lshal command lists all devices the hardware abstraction layer (HAL) knows about, which should be most hardware on your system. lshw: The lshw command lists hardware on your system, including maker, type, and where it is connected. Searching and Editing Text Files grep: The grep command allows you to search inside a number of files for a particular search pattern and then print matching lines. For example, grep blah file will search for the text "blah" in the file and then print any matching lines. sed: The sed (or Stream EDitor) command allows search and replace of a particular string in a file. For example, if you want to find the string "cat" and replace it with "dog" in a file named pets, type sed s/cat/dog/g pets. Both grep and sed are extremely powerful programs. There are many excellent tutorials available on using them, but here are a few good Web sites to get you started: www.panix.com/~elflord/unix/grep.html www.itworld.com/Comp/2378/swol-1199-unix101/ Three other commands are useful for dealing with text. cat: The cat command, short for concatenate, is useful for viewing and adding to text files. The simple command cat FILENAME displays the contents of the file. Using cat FILENAME file adds the contents of the first file to the second. cat filename cat filename | more cat filename | less less /etc/passwd cat /etc/passwrd | more cat -b filename Display non-empty lines in file cat -n filename Show line numbers for all lines cat -E filename Show end of line as $ cat -s filename Show only 1st of consecutive blank lines cat filename1 filename2 Concatenate multiple files to scren cat filename1 finename2 > newfile Concatenate files, create newfile tac filename Show contents of file in reverse order nano: Nano is a simple text editor for the command line. To open a file, use nano filename. Commands listed at the bottom of the screen are accessed via pressing Ctrl followed by the letter. less: The less command is used for viewing text files as well as standard output. A common usage is to pipe another command through less to be able to see all the output, such as ls | less. Dealing with Users and Groups You can use the following commands to administer users and groups. adduser: The adduser command creates a new user. To create a new user, simply type sudo adduser $loginname. This creates the user's home directory and default group. It prompts for a user password and then further details about the user. passwd: The passwd command changes the user's password. If run by a regular user, it will change his or her password. If run using sudo, it can change any user's password. For example, sudo passwd joe changes Joe's password. who: The who command tells you who is currently logged into the machine. addgroup: The addgroup command adds a new group. To create a new group, type sudo addgroup $groupname. deluser: The deluser command removes a user from the system. To remove the user's files and home directory, you need to add the -remove-home option. delgroup: The delgroup command removes a group from the system. You cannot remove a group that is the primary group of any users. Getting Help on the Command Line This section provides you with some tips for getting help on the command line. The commands --help and man are the two most important tools at the command line. Virtually all commands understand the -h (or --help) option, which produces a short usage description of the command and its options, then exits back to the command prompt. Try man -h or man --help to see this in action. Every command and nearly every application in Linux has a man (manual) file, so finding such a file is as simple as typing man command to bring up a longer manual entry for the specified command. For example, man mv brings up the mv (move) manual. Some helpful tips for using the man command include the following. Arrow keys: Move up and down the man file by using the arrow keys. q: Quit back to the command prompt by typing q. man man: man man brings up the manual entry for the man command, which is a good place to start! man intro: man intro is especially useful. It displays the Introduction to User Commands, which is a well-written, fairly brief introduction to the Linux command line. There are also info pages, which are generally more in-depth than man pages. Try info info for the introduction to info pages. Searching for Man Files If you aren't sure which command or application you need to use, you can try searching the man files. man -k foo: This searches the man files for "foo". Try man -k nautilus to see how this works. Note: man -k foo is the same as the apropos command. man -f foo: This searches only the titles of your system's man files. Try man -f gnome, for example. Note: man -f foo is the same as the whatis command. Using Wildcards Sometimes you need to look at or use multiple files at the same time. For instance, you might want to delete all .rar files or move all .odt files to another directory. Thankfully, you can use a series of wildcards to accomplish such tasks. * matches any number of characters. For example, *.rar matches any file with the ending .rar. ? matches any single character. For example, ?.rar matches a.rar but not ab.rar. [characters] matches any of the characters within the brackets. For example, [ab].rar matches a.rar and b.rar but not c.rar. [!characters] matches any characters that are not listed. For example, [!ab].rar matches c.rar but not a.rar or b.rar. Executing Multiple Commands Often you may want to execute several commands together, either by running one after another or by passing output from one to another. Running Sequentially If you need to execute multiple commands in sequence but don't need to pass output between them, there are two options based on whether or not you want the subsequent commands to run only if the previous commands succeed or not. If you want the commands to run one after the other regardless of whether or not preceding commands succeed, place a ; between the commands. For example,if you want to get information about your hardware, you could run lspci ; lsusb, which would output information on your PCI buses and USB devices in sequence. However, if you need to conditionally run the commands based on whether the previous command has succeeded, insert && between commands. An example of this is building a program from source, which is traditionally done with ./configure, make, and make install. The commands make and make install require that the previous commands have completed successfully, so you would use ./configure && make && make install. Passing Output If you need to pass the output of one command so that it goes to the input of the next, after the character used between the commands, you need something called a pipe, which looks like a vertical bar or pipe (|). To use the pipe, insert the | between each command. For example, using the | in the command ls | less allows you to view the contents of the ls more easily. gzip gzip filename Compress filename gzip filename.ext gzip -d filename.gz Decompress filename.gz gzip -f filename Force compression of filename gzip -k filename Compress and keep original filename gzip -l filename.gz Show compression stats of filename.gz gzip -r foldername Separately compress each file in each subfolder gzip -t filename Test validity of filename gzip -1 filename Least compression gzip -9 filename Maximum compression Do not use gzip on standard zip files. Use zip and unzip. VI The default editor that comes with the UNIX operating system is called vi (visual editor). [Alternate editors for UNIX environments include pico and emacs, a product of GNU.] The UNIX vi editor is a full screen editor and has two modes of operation: Command mode commands which cause action to be taken on the file, and Insert mode in which entered text is inserted into the file. In the command mode, every character typed is a command that does something to the text file being edited; a character typed in the command mode may even cause the vi editor to enter the insert mode. In the insert mode, every character typed is added to the text in the file; pressing the (Escape) key turns off the Insert mode. While there are a number of vi commands, just a handful of these is usually sufficient for beginning vi users. To assist such users, this Web page contains a sampling of basic vi commands. The most basic and useful commands are marked with an asterisk (* or star) in the tables below. With practice, these commands should become automatic. NOTE: Both UNIX and vi are case-sensitive. Be sure not to use a capital letter in place of a lowercase letter; the results will not be what you expect. To Get Into and Out Of vi To Start vi To use vi on a file, type in vi filename. If the file named filename exists, then the first page (or screen) of the file will be displayed; if the file does not exist, then an empty file and screen are created into which you may enter text. vi: filename edit filename starting at line 1 vi -r filename recover filename that was being edited when system crashed To Exit vi Usually the new or modified file is saved when you leave vi. However, it is also possible to quit vi without saving the file. Note: The cursor moves to bottom of screen whenever a colon (:) is typed. This type of command is completed by hitting the Return (or Enter) key. :x Return quit vi, writing out modified file to file named in original invocation :wq Return quit vi, writing out modified file to file named in original invocation :q Return quit (or exit) vi :q! Return quit vi even though latest changes have not been saved for this vi call Moving the Cursor Unlike many of the PC and MacIntosh editors, the mouse does not move the cursor within the vi editor screen (or window). You must use the the key commands listed below. On some UNIX platforms, the arrow keys may be used as well; however, since vi was designed with the Qwerty keyboard (containing no arrow keys) in mind, the arrow keys sometimes produce strange effects in vi and should be avoided. If you go back and forth between a PC environment and a UNIX environment, you may find that this dissimilarity in methods for cursor movement is the most frustrating difference between the two. In the table below, the symbol ^ before a letter means that the key should be held down while the letter key is pressed. j [or down-arrow] move cursor down one line k [or up-arrow] move cursor up one line h [or left-arrow] move cursor left one character (Backspace) l [or right-arrow] move cursor right one character (space) 0 move cursor to start of current line (the one with the cursor) $ move cursor to end of current line w move cursor to beginning of next word b move cursor back to beginning of preceding word :0 or 1G move cursor to first line in file :n or nG move cursor to line n :$ or G move cursor to last line in file Screen Manipulation The following commands allow the vi editor screen (or window) to move up or down several lines and to be refreshed. ^f move forward one screen ^b move backward one screen ^d move down (forward) one half screen ^u move up (back) one half screen ^l redraws the screen ^r redraws the screen, removing deleted lines Adding, Changing, and Deleting Text Unlike PC editors, you cannot replace or delete text by highlighting it with the mouse. Instead use the commands in the following tables. Perhaps the most important command is the one that allows you to back up and undo your last action. Unfortunately, this command acts like a toggle, undoing and redoing your most recent action. You cannot go back more than one step. u UNDO WHATEVER YOU JUST DID; a simple toggle The main purpose of an editor is to create, add, or modify text for a file. Inserting or Adding Text The following commands allow you to insert and add text. Each of these commands puts the vi editor into insert mode; thus, the Esc key must be pressed to terminate the entry of text and to put the vi editor back into command mode. i insert text before cursor, until Esc hit I insert text at beginning of current line, until Esc hit a append text after cursor, until Esc hit A append text to end of current line, until Esc hit o open and put text in a new line below current line, until Esc hit O open and put text in a new line above current line, until Esc hit Changing Text The following commands allow you to modify text. r replace single character under cursor (no Esc needed) R replace characters, starting with current cursor position, until Esc hit cw change the current word with new text,starting with the character under cursor, until Esc hit cNw change N words beginning with character under cursor, until Esc hit; e.g., c5w changes 5 words C change (replace) the characters in the current line, until Esc hit cc change (replace) the entire current line, stopping when Esc is hit Ncc or cNc change (replace) the next N lines, starting with the current line, stopping when Esc is hit Deleting Text The following commands allow you to delete text. x delete single character under cursor Nx delete N characters, starting with character under cursor dw delete the single word beginning with character under cursor dNw delete N words beginning with character under cursor; e.g., d5w deletes 5 words D delete the remainder of the line, starting with current cursor position dd delete entire current line Ndd or dNd delete N lines, beginning with the current line; e.g., 5dd deletes 5 lines Cutting and Pasting Text The following commands allow you to copy and paste text. yy copy (yank, cut) the current line into the buffer Nyy or yNy copy (yank, cut) the next N lines, including the current line, into the buffer p put (paste) the line(s) in the buffer into the text after the current line Other Commands Searching Text A common occurrence in text editing is to replace one word or phase by another. To locate instances of particular sets of characters (or strings), use the following commands. /string search forward for occurrence of string in text ?string search backward for occurrence of string in text n move to next occurrence of search string N move to next occurrence of search string in opposite direction Determining Line Numbers Being able to determine the line number of the current line or the total number of lines in the file being edited is sometimes useful. :.= returns line number of current line at bottom of screen := returns the total number of lines at bottom of screen ^g provides the current line number, along with the total number of lines, in the file at the bottom of the screen Saving and Reading Files These commands permit you to input and output files other than the named file with which you are currently working. :r filename Return read file named filename and insert after current line (the line with cursor) :w Return write current contents to file named in original vi call :w newfile Return write current contents to a new file named newfile :12,35w smallfile write the contents of the lines numbered 12 through 35 to a new file named smallfile :w! prevfile write current contents over a pre-existing file named prevfile