Linux

To Bottom

The Terminal

[username@machinename ~] $

Do not use spaces in folder and file names -- Linux does not like that at the command line!

To Top

Wildcards * ?

To Top

Bash (Bourne Again SHell) / Terminal Commands

A

alias Create an alias: alias [-p] [name[=value] ...]

apropos, man -k Search manual for appropriate command

aspell Spell Checker: aspell check myfile.txt

To Top

B

bg Send process to background using jobspec: bg %jobspec

To Top

C

cal Calendar

cat Concatenate and display the content of files: cat [-Ans...] [File]...

cd Change directory: cd [options] [directory]

chgrp Change group ownership: chown [options]... :group file...

chmod Change access permissions

chown Change file owner and group: chown [owner] [:group] file...

clear Clear terminal screen

comm Compare two sorted files

cp Copy: cp [-airuv]... [source] [destination]

cut Divide a file into several parts: cut [-c -d: -f]... [FILE]...

To Top

D

date Display/change date/time: date [option]... [format]

df Display free disk space: df [option]... [file]...

diff Display the differences between two files: diff [-c -i -u] FILES

To Top

E

echo Display message on screen: echo [-e]... [string]...

expand Convert tabs to spaces

exit Exit from program, shell or log out of network: exit

export Set environmental variable

To Top

F

fg Send process to foreground specifying jobspec

file Determine file type: file

find Search for files that meet a desired criteria

free Display memory usage: free [-b|-k|-m|-g|-h]

ftp File Transfer Protocol: ftp myFileServer

To Top

G

grep Search files for specific text: grep [-cEhivlLn...] regex [file...]

To Top

H

hash Remember the full pathname of a name argument: hash [-r] [-p filename] [name]

head Output the first part of files: head [options]... [file]...

help Help for shell builtins

history Command History: history -c

hostname Print or set system name

To Top

I

id Print user and group id's: id [options]... [username]

info Manual in info format: info [command]

To Top

J

jobs List active jobs

join Join lines on a common (sorted) field as in a relational DB

To Top

K

kill Kill a process by specifying PID or %jobspec

killall Kill multiple processes by name

To Top

L

less Display output one screen at a time: less [options]

let Perform arithmetic on shell variables

ln Create a link to a file: ln [-s]...

*a hard link cannot reference a directory or a file outside its own filesystem

locate Find files (updatedb = update locate database)

ls List files: ls [-aFhilrS | -t]... [.. | ~ | /etc]...

To Top

M

man Manual: man [option]... [section] [command]

  1. user commands
  2. interfaces for kernel
  3. interfaces to C library
  4. device nodes and drivers
  5. file formats
  6. games
  7. misc.
  8. admin

mkdir Create new directory: mkdir [-p]... [directory]...

more Display output one screen at a time, forward only

mv Move or rename files or directories: mv [iuv]... [source] [destination]

To Top

N

netstat Networking information: netstat -r; netstat -ie ~ ifconfig

To Top

O

P

passwd Modify a user password

paste Merge lines of files: paste [-d:]... [file]...

ping Test a network connection: ping -c5

printenv Print environment variables

printf Format and print data

ps Process status (gives PID)

pwd Print Working Directory: pwd [option]...

To Top

Q

R

read Read a line from standard input: read -p "Press enter to continue"

rm Remove files: rm [-irfv]... [file]

To Top

S

scp Secure copy (remote file copy)

set View all variables, set shell variables and functions

sftp Secure File Transfer Program

shutdown Shutdown or restart linux

sleep Delay for a specified time

sort Sort text files: sort [options] [file...]

source Run commands from file: source filename [arguments]

ssh Secure Shell client (remote login program)

stat Display file or file system status

su Substitute user identity: su[-l|-p] [user] or su -c 'command'

sudo Execute command as superuser or another user: sudo [command]...

To Top

T

tail Output the last part of files: tail [options]... [file]...

tee Redirect output to multiple files: tee [options]... [file]...

top List processes running on the system

touch Change file timestamps / create file: touch [options]... File...

tr Translilterate, squeeze, delete characters

traceroute tracepath, Trace Route to Host

tree list directories in tree format: tree -aCdL 1

type Identify command type: type [-atp] [name ...]

To Top

U

unalias Remove an alias: unalias [-a] [name ... ]

umask Users file creation mask

uniq Report or filter out repeated lines in a file: uniq [-c -d -i -fn -sn -u]... [InputFile [OutputFile]]

unset Remove variable or function names: unset [-fv] [name]

To Top

V

W

wc Print byte, word, and line counts: wc [-c|-i|-l|-w]... [file]...

wget Retrieve web pages or files via HTTP, HTTPS or FTP

which Display users path to a command: which [options] [--] program_name [...]

whatis Display brief description of command: whatis [command]...

who List all usernames currently logged in: who [options] [file] [am i]

whoami Display the current user id and name: whoami [options]

To Top

X

xargs Execute command, passing constructed argument list(s): xargs [options] [command]

To Top

Linux File System

     /bin - binaries essential to boot system and run
     /boot
        /grub/grub.conf or menu.lst        
        /RAM disk, boot loader
        /vmlinuz (kernel)
     /dev - device files for system
           (block and charactor type)
     /etc - configuration files for system        
        /passwd, group, rc, group, crontab
        /rc.d/rc.sysinit
        /bash/bash.rc                        
        /profile
        /fstab - devices mounted at boot
     /home
        /.bash_profile
        /.bash_login
        /.bashrc
        /.profile
     /lib - libraries, support for symbolic linking
     /lost+found - for filesystem recovery
     /media - temporary mount points (newer systems)
     /mnt - temporary mount points (older systems)
     /root - home directory for root (super user)
     /tmp

To Top

File Type

To Top

File Mode

Mode File Directory
r open/read list contents (x must be set also)
w write create/delete/rename contents (x must be set also)
x execute enter

To Top

Redirecting stdin(0), stdout(1) and stderr(2)

To Top

Pipe, tee

To Top

Escape Characters

To Top

Arithmetic and Base Expansion

To Top

Regular Expression Metacharacters ^ $ . ? * + - | [ ] { } ( ) \

To Top

POSIX Character Classes

To Top

Text Editors

vi editor

To Top

vim

vi iMproved - a programmers text editor.

To Top

Nano

Nano's ANOther editor, an enhanced free Pico clone.

To Top

Emacs

Text editor that is really an IDE

To Top

Pico

Pico (Pine composer) is a text editor for Unix and Unix-based computer systems

To Top

Scripts

Script must start with the shebang:

Script must be executable:

Script must be on the path:

To Top

If...Then...Else


    echo –n “Who is your favorite instructor? “
    read INST
    if [ “$INST” = “Killham” ]
    then
        echo “Good choice, you get an A!”
    else
        echo “ Would you like to rethink your answer?”
    

To Top

For Loop


    for name in Karen Jo Barb Linda Laurie Kim
    do
        echo “Welcome $name”
    done
    

To Top

While Loop


    echo –n “Try to guess my favorite instructor “
    read guess
    while [ “$guess” != “Schuster” ]; do
    echo “No, not that one. Try again. “;
    read guess
    done
    

To Top

Example Script


    #!/bin/bash
    clear
    #echo -n "Enter name of file to create: "    
    #read myString
    read -p "Enter name of file to create: " myString
    touch $myString
    free > $myString
    echo >> $myString
    df >> $myString
    echo >> $myString
    echo "Results from ping -c 3 www.unl.edu"  >> $myString
    ping -c 3 www.unl.edu >> $dateFile
    

To Top

Installations and Updates

To Top

Tarball

sudo tar -cvpzf [Create Verbose PreservePermissions z=compress Filename] backup.tar.gz --exclude=/mnt /directoryToBeBackedUp

sudo tar -xvpzf [eXtract Verbose PreservePermissions z=uncompress File] backup.tar.gz -C /recoveryDirector [ChangeDirectory]

To Top

Cron Job


    sudo crontab -e & choose text editor
    m h dom m dow comm
    Min 0-59
    Hour 0-23
    DayOfMonth 1-31
    Month 1-12
    DayOfWeek 0-6 (Sun to Sat)
    

To Top

Administration


    su = change ID or become Super User
    sudo = Super User Do
    gksudo = for apps using a GUI
    visudo = edits sudoers file
    sudo adduser napes
    sudo userdel napes
    sudo passwd = change password
    sudo vi /etc/passwd = etc/passwd contains user names, home directories...
    sudo groupadd napesGroup
    sudo groupdel napesGroup
    sudo adduser napes napesGroup
    sudo deluser napes napesGroup
    sudo vi /etc/group
    chmod 777 example.txt = gives Read, Write & eXecute permissions to user, group and others to file example.txt eg. 111 111 111
    

To Top

System


    sudo apt-get install
    ubuntu-restricted-extras
    echo $SHELL = Shell you are using
    BASH (Bourne-Again SHell) freeware, most common, Brian Fox and Chet Ramey.
    CSH (C SHell) The C shell's syntax and usage are very similar to the C programming language.
    KSH (Korn SHell) David Korn	AT & T Bell Labs.
    TCSH enhanced, compatible version of the Berkeley UNIX C shell (CSH).
    ps = report a snapshot of the current process
    es
    pa aux = List all processes in detail running on the system
    uname = get name and information about current kernel
    version = kernel info
    df -h = report file system disk space usage
    df -i
    du -cksh = size of current folder
    du -cksh file.examp = size of file.examp
    sudo du -s -h -x /* = estimate file space usage
    sudo top  (+ h) = "task manager"
    ipcs -m = provide info on ipc facilities
    inxi -xG =
    sleep
    kill PID
    killall
    processName
    xkill = starts GUI for killing windows
    cd /boot/grub/
    vi menu.lst
    

To Top

Formatting Floppy Disk


    $ dd bs=512 count=2880 if=/dev/zero of=floppy.img
    $ mkfs.msdos floppy.img
    $ sudo mount -o loop image.img /media/floppy/
    <<<copy your files on to the "drive" now>>>
    $ sudo umount /media/floppy/
        

To Top

Networking


    whois
    netstat -print network connections, routing tables, interface...
    sudo ifconfig
    sudo dhclient = release/renew ip address
    sudo vi /etc/resolv.conf
    sudo vi/etc/network/interfaces
    sudo /bin/hostname (or just hostname)
    sudo /bin/hostname name = renames computer to "name"
    sudo /etc/init.d/exampleService stop
    sudo /etc/init.d/exampleService start
    sudo /etc/init.d/exampleService restart
    sudo service networking restart
    sudo vim /etc/vsftpd.conf
    sudo service vsftpd restart
    

To Top

WireShark


    sudo apt-get install wireshark libcap2-bin
    sudo groupadd wireshark
    sudo adduser napes wireshark
    sudo chgrp wireshark /usr/bin/dumpcap
    sudo chmod 755 /usr/bin/dumpcap
    sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap
    

To Top

Firewall


    sudo apt-get install gufw
    turn on
    add rules (show extended options) + :
    select number 0, deny, service, SSH
        or
    sudo ufw
    status verbose
    sudo ufw allow/deny x.x.x.x
    sudo ufw allow/deny [port#]
    

To Top

Linux Mint

Unable to Mount Floppy Error [solved]:

sudo mateconf-editor apps\caja\preferences\media_automount (uncheck),

To Top

Decryption Prompt Not Appearing [solved]:

sudo vi /etc/default/grub

Add this line

GRUB_GFXPAYLOAD_LINUX=text

sudo update-grub

sudo reboot

To Top

Kernel Won't Update - Drive Full [solved]:

Separate partition for /boot seems to for LVM and/or "full" disk encryption on the rest of the drive.

The likely cause of this issue is too many previous kernels installed. The /boot directory contains all of the kernel images. The separate partition for /boot is only around 227MB in size. This partition is full. Ubuntu issues kernel updates which bump the version number in the package name fairly frequently even for long term stable versions, so over time if you keep the system up to date, the /boot directory will grow.

Find the currently running kernel with:

uname -r

List all installed kernels with:

aptitude search ~ilinux-image

This may also return some packages that aren't kernels. There is usually no need for more than two kernels to be installed - the kernel in use and, as a fallback, its predecessor.

Remove older kernels, one by one, like this:

sudo apt-get autoremove linux-image-3.2.0-23-generic

Substitute "3.2.0-23-generic" with the actual kernel version you want to remove! Don't remove packages such as linux-image-generic! Do not to remove the currently running kernel!

To Top

NVIDIA

sudo apt-get install nvidia-current-updates

To Top

Commandes Dispo (TI-89 Titanium)

Voici la liste des commandes disponibles pour le kernel (dans le terminal):


    cd
    chroot - change root directory?
    copy
    cp
    echo
    getfold
    hostname
    hwclock - query or set the hardware clock (RTC)
    logname
    ls
    mcd
    mdel
    mkdir
    mmd
    mrd
    netstat
    rm
    rmdir
    rusers
    sleep
    uname
    version
    who
    

To Top