Basic Linux Terminal Commands

  • Adding a user
    While logged in as root, type in the shell:

    replace username with the username you wish

    adduser username

    Deleting a user:
    While logged in as root, type replace username with the user name you wish to delete.

    userdel username

    Change login password
    To set the password for a specific user, replace username with the name of the user. By typing simply:

      passwd username

    To change the current password for the user you are logged in as:


    Change directories

    cd - Used to Change Directories

    Usage: cd /[directory]

    cd /tmp


    cd ../

    (moves back one directory)

    Move to your home directory:


    Check the man pages for more info:

    man cd

  • Downloading a file using the terminal command wget

    First cd to the tmp directory

    cd /tmp

    Example: wget

    Copy files

    cp - Used to copy files or directories from one location to another. We can use the above example for this.

    Example: cp /tmp/site-logo.png /var/www/httpdocs

    [as httpdocs is your root web directory]

    To move ALL files from one directory to another:

    Example: cp /tmp/files/* /var/www/httpdocs

    (the “*” tells the machine to copy everything in /tmp/files to /var/www/)

    Check your man pages for more information on the cp command**

    man cp

  • Renaming files
    mv - Command used to move or rename files
    Usage: mv file location
    Usage: mv filename::newfilename

    Example: mv tmp/site-logo.png /tmp/lime-it.png

    Read the manual: man mv

    Moving files
    mv - Used to move or rename files
    Usage: mv file location (to move)

    Example:mv index.html /var/www/index.html

    For more information, in a terminal and read the manual pages, type: man mv

  • Editing files
    The default editor installed with most all distros of linux is VIM , or

    vi filename

    Vim is an advanced command line editor, you should consider learning the commands.

    You can however also use nano To edit a file with nano, simply run:

    nano filename

    This will open up the file and allow to you edit the file. At the bottom of the screen you will notice the various commands that you have access to with nano. If you wish to save the file and exit, simply hold down the control key and hit the x key on your keyboard.

    You will be asked to confirm this edit, if you have permissions to do so, once you confirm by typeing y, the file will be edited and nano will exit.

  • Deleting files

    To delete a file you must first have write permission to it. Once you have write permission, in a terminal run:
    rm filename\

    There is no “Recycle Bin” in Linux so once you delete a file, it’s gone for good.

    Being safe, find the files first and actually look at what you will be deleting! find . -type f -name foo\*

    When removing files, you may use an astrix “*” as a wildcard flag to remove certain files, for example if I wanted to remove all files that began with “foo” , I would run:

    find . -type f -name foo\* -exec rm {} \;

    If anyone tells you to run rm -rf / as root, DO NOT LISTEN TO THEM. Running this command will delete all the files/directories on your Linux system. And render the machine completely useless with zero chance of recovery!

    You should not be running as root to begin with! Learn to use a secondary user, and as well the “su” command or “Super User” as general usage dictates.

    Deleting directories
    If you have ownership to the directory and the directory is empty, you can simply type

    rmdir directoryname to remove the directory.

    If the directory is not empty and you wish to simply delete it and all its contents, run:

    rm -rf directoryname[/code] Please be careful with the -rf flag, as it will remove everything in the specified directory including sub directories. With root access and the rm -rf command you can wipe out your entire system if you make an error.

  • This post is deleted!

  • Listing directory contents

    ls - To list the contents of a directory

    Usage: ls [flags]

    Example: ls (To list the current directory)

    Example: ls /tmp (To list the contents of /tmp)

    Example: ls -a (To list hidden files)

    Example: ls -l (To list file/directory permissions and file sizes)

    Example: ls -al /tmp(To list all files and permissions in /tmp)

    Example: ls -il (To get the inode number, permissions, owner, file sizes, UID and timestamps of all files in current directory)

    For more information, in a terminal, type man ls

  • This post is deleted!

Log in to reply

Tmux Commands

screen and tmux

A comparison of the features (or more-so just a table of notes for accessing some of those features) for GNU screen and BSD-licensed tmux.

The formatting here is simple enough to understand (I would hope). ^ means ctrl+, so ^x is ctrl+x. M- means meta (generally left-alt or escape)+, so M-x is left-alt+x

It should be noted that this is no where near a full feature-set of either group. This - being a cheat-sheet - is just to point out the most very basic features to get you on the road.

Trust the developers and manpage writers more than me. This document is originally from 2009 when tmux was still new - since then both of these programs have had many updates and features added (not all of which have been dutifully noted here).

Action tmux screen
start a new session tmux OR
tmux new OR
tmux new-session
re-attach a detached session tmux attach OR
tmux attach-session
re-attach an attached session (detaching it from elsewhere) tmux attach -d OR
tmux attach-session -d
screen -dr
re-attach an attached session (keeping it attached elsewhere) tmux attach OR
tmux attach-session
screen -x
detach from currently attached session ^b d OR
^b :detach
^a ^d OR
^a :detach
rename-window to newname ^b , <newname> OR
^b :rename-window <newn>
^a A <newname>
list windows ^b w ^a w
list windows in chooseable menu ^a "
go to window # ^b # ^a #
go to last-active window ^b l ^a ^a
go to next window ^b n ^a n
go to previous window ^b p ^a p
see keybindings ^b ? ^a ?
list sessions ^b s OR
tmux ls OR
tmux list-sessions
screen -ls
toggle visual bell ^a ^g
create another window ^b c ^a c
exit current shell/window ^d ^d
split window/pane horizontally ^b " ^a S
split window/pane vertically ^b % ^a |
switch to other pane ^b o ^a <tab>
kill the current pane ^b x OR (logout/^D)
collapse the current pane/split (but leave processes running) ^a X
cycle location of panes ^b ^o
swap current pane with previous ^b {
swap current pane with next ^b }
show time ^b t
show numeric values of panes ^b q
toggle zoom-state of current pane (maximize/return current pane) ^b z
break the current pane out of its window (to form new window) ^b !
re-arrange current panels within same window (different layouts) ^b [space]
Kill the current window (and all panes within) ^b killw [target-window]
  • Mount NFS from Truenas

    mkdir -p /media/rick/pool1 chown -R rick:rick /media/rick/pool1

    Add the automount to: /etc/fstab

    truenas.thecave:/mnt/pool1 /media/rick/pool1 nfs user,auto 0 0

    Retstart Nautilus to see the share in files:

    killall nautilus

    For other shares, just repeat the same process under directory ‘media’ with the name of the share substituted

    read more
  • Again running smartctl after all is said and done:

    smartctl --all /dev/sda

    ddrescue-smartctl-after-rescue.png ddrescue-smartctl-2.png

    Yet an old drive in itself, I run the wheels off of them, and monitor regularly as anyone should.

    read more