Linux users are expected to interact with the Linux systems quickly and efficiently.
A bare minimum number of commands will get you by, but if you are interested in sharing what works for you, or common/favorite one-liners or pieces of your bash script continue reading.
And if it isn't on this page, of course, check Google, StackOverflow, and the man pages (RTFM = Read the Fine Manual).
man
show the manual for the command, press q
to quit, spacebar, page up, page down, arrows to scroll.
<command> -h
try to show the help or usage of a command.
<command> -?
try to show the help or usage of a command.
In bash, you can "glob" together a list of files by throwing in some wildcards.
abc*
Find abcd, abce, abcdefghij... and so on and anything else that starts with abc.
"ab c"
Include the space in the name, can have variables inside.
'ab c'
Include the space in the name, variables and special characters are treated like regular text.
ls
list files, similar to dir
in windows.
ll
aliased to ls -l
, shows columns of info about the list of the files in the directory.
tree
shows all the files in a directory tree.
../
up a directory.
./
in the current directory.
/
the root of the harddrive (like c: in windows).
pwd
display the present working directory.
cd
change directory.
~
shorthand for the current user's home directory, like /home/user
.
<tab>
auto completes a partially written filename.
<tab><tab>
lists all the possible filenames for the typed out prefix before the cursor.
cat
dumps the whole file to the screen.
less
lets you scroll up and down on the file, press q to quit.
more
lets you page down, only.
most
lets you scroll up, down, left and right.
head
show the first few lines of a file.
tail
show the last few lines of a file.
|
pipe the output of the command on the left to the command on the right.
echo
show one line of text.
clear
clear the current page of text and force the current line to the top of the page.
<Shift><PgUp>
scroll up to previous lines of text on the terminal.
resize
fixes poor wrapping of text at the command prompt, necessary after resizing the window, to have the terminal recognize the new column width..
XConfig needs to be configured properly for this to work:
- XSelection needs to be changed from
Clipboard
toPrimary
. - The session needs to be restarted to see the changes.
Start a selection with a click drag.
Fill in a selection to the end with a right click.
Any selection in linux is auto-copied to the clipboard.
Paste in xterm (the default terminal in MICADS) with a center click.
Not installed, but future tool for ease of clipboard access is xclip
.
In general terminal editors are faster to open and interact with files. On remote systems with lower bandwidth and higher latency, terminal editors are superior.
nano
terminal editor... Ctrl+ to save, exit, etc..
vi, vim
terminal editor... multiple modes, Read, Display, Visual, etc, many special commands start with :
.
navigation with hjkl
keys... press ESC
to get out of a mode...
emacs
terminal editor... Ctrl+ or Alt+ (short handed to C and M ) for special interactions.
gedit, kate, gvim, xemacs
graphical editors.
touch
make a file, or update the timestamp on a file.
>
capture output on the left into the file or handle on the right.
>>
append output on the left onto the filename on the right.
mkdir
make a directory.
cp
copy a file or directory.
mv
move and/or rename a file.
scp
secure copy a file or directory from one system to another.
rsync
remote synchronization between two computers (very powerful).
rm
remove a file or directory (needs -rf
for non-empty directories).
grep
general purpose find inside files tool, successors include: awk, ag.
find
find a specific filename and sometimes do something with it.
which
find a file (usually a script or binary executable) in the PATH folders list.
locate
find a filename (or pattern) on the computer that was in the snapshot index last night at midnight.
uniq
show only unique lines.
sort
show the lines sorted alphabetically.
$var
the dollar sign indicates the start of a variable, usually an environment variable, e.g. $PATH.
alias
makes a nickname for command(s) with specific options, like ll
= ls -l
and gotis
, or lists all aliases.
function
makes a reusable function or subroutine, that can handle parameters passed in, a la bash scripting.
export
makes a variable that lives for the length of the "session" that the user is logged in.
env
queries and lists all the "exported" variables in the '''env'''ironment for use with the session/login.
xterm
the text, the command prompt, etc that the session lives in, useful for launching another window.
set
used for changing/listing options for bash. Like "set -x" and "set +x" to turn on and off echoing all commands..
!!
"bang, bang", previous command.
!$
"bang, cash", previous end parameter.
!xxxxx
"bang", some letters for previous command, executes the last command that started with those letters.
<ESC>,<Ctrl><E>
Expands one of the above shortcuts to its full length.
<Ctrl><R>
Reverse search through command history, with interactive input, repeat to search further back.
su
switch user, start a session as a different user, or without parameters, starts a super user session.
ssh
tunnel into another system with a secure shell.
exit
end a session or shell.
logout
end a session or shell.
script
start a new bash session and save all the text output for later review.
screen
screen manager with terminal emulation, a nify way to keep persistent sessions open across logins, also does shared sessions easily.
screen -d -m -S shared
screen -x shared
tmux
terminal multiplexer, a newer nifty way to keep persistent sessions open across logins (utf support, not installed).
ln -s
create a symbolic link, one file pointing to the actual file somewhere else on the harddrive.
unlink
remove a symbolic link.
Ctrl+Z
Pause a process.
bg
Move a paused process to the background jobs.
fg
Move a background job or a paused job to the foreground.
jobs
List all the jobs associated with the current session.
Ctrl+C
Kill the current foreground process.
top
View the current running process on the screen, q to quit, or Ctrl-c.
htop
Like top, but more colorful and a little more friendly.
w
list all the other users on the system, and login time, idle time, last command, etc.
wall
broadcast a message to everyone else on the computer.
write
send a message to a single other user login to that computer.
`echo "message to send" | write <username>`
finger
get identification information about a user's name.
getent passwd "user"
gets entries about a user from the passwd administrative database.
lp
sends a file to the printer address under LPDEST.
chmod
change the permissions for a file, who can execute, read, write, etc..
chgrp
change what group has access to a file.
chown
change what user owns the file.
sudo
'''S'''uper '''u'''ser '''do''', or take action with elevated permissions for the current user.
tar
stands for tape archive, many options for compressing and decompressing files, great for .tar, .tar.bz, .tar.gz and others.
unzip
unzip a file.
diff
show all the differences between two files.
tkdiff
show all the differences between two files, graphical window.
svn
centralized versioning system.
git
distributed versioning system, awesome (see [attachment:progit-en.1084.pdf Git Book (cached)] or [https://progit2.s3.amazonaws.com/en/2016-03-22-f3531/progit-en.1084.pdf Git Book]).
Script files are read a line at a time, and interpreted at run time, plain text files.
perl
files end in pl, original support for Regular Expressions (aka regex or regexp).
python
files end in py, popular language.
bash
stands for borne again shell, and is the language that handles all the input to the command-line.
sh
posix standard shell command script.
ruby
files end in rb, popular language, newer than python.
These files are compiled down to a binary file.
gcc
c compiler.
g++
c++ compiler.
ld
linker, connects complied .o files into an executable.
make
manages compiling and linking process for most projects in a Makefile.
configure
provides inputs for the Makefile that are specific to the system/install.
du
'''d'''isk '''u'''sage, estimate file space usage - space used under a particular directory or files on a file system..
du -sh ./*
show the filesize of each sub folder in the current directory
df
'''d'''isk '''f'''ree, report file system disk space usage, also useful for checking for nfs mounts.
df -h
show all the mounted disks and their used/available size
dd
'''d'''ata '''d'''escription, convert and copy a file, also used for cloning partitions and harddisks.
From an ssh session, run gnome-session
to start a GNOME/Ubuntu style desktop or run plasma-desktop
to start a KDE/Plasma style desktop.
The gnome session is the default way that a ubuntu user logs into the computer.
Note: search one of these on this page to find an app.
| Notes | Shortcut | Name | Comment | Categories | Exec |
You can find these apps in the kickoff launcher in the corner of plasma-desktop
.
Generate the table below with the following script:
cd /usr/share/applications
find_and_strip ()
{
str=$(grep -rhoP "(?<=^($1)).*" $2);
echo $str;
}
(
for i in * */*;
do
if [ -d $i ]; then
continue;
fi;
echo -e "$i\t$(find_and_strip "Name=" $i)\t$(find_and_strip "Comment=" $i)\t$(find_and_strip "Categories=" $i)\t$(find_and_strip "Exec=" $i)";
done) | xclip