Skip to content

Instantly share code, notes, and snippets.

@peteristhegreat
Last active September 2, 2023 17:09
Show Gist options
  • Save peteristhegreat/01ffb3573ee503cb6ace84d6fb825a48 to your computer and use it in GitHub Desktop.
Save peteristhegreat/01ffb3573ee503cb6ace84d6fb825a48 to your computer and use it in GitHub Desktop.
Linux notes

Miscellaneous Linux Commands

Introduction

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.

General Links

And if it isn't on this page, of course, check Google, StackOverflow, and the man pages (RTFM = Read the Fine Manual).

Manual Lookup

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.

Wildcards

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.

Listing Files

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.

Viewing Text

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..

Copy / Paste

XConfig needs to be configured properly for this to work:

  • XSelection needs to be changed from Clipboard to Primary.
  • 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.

Text Editors

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.

Creating/Deleting Files and Folders

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).

Finding and Filtering Text

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.

Bash Variables and Functions

$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..

Bash History

https://www.digitalocean.com/community/tutorials/how-to-use-bash-history-commands-and-expansions-on-a-linux-vps

!!
"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.

Sessions

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).

Linking & Symlinks

ln -s
create a symbolic link, one file pointing to the actual file somewhere else on the harddrive.

unlink
remove a symbolic link.

Process Control

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.

Other Users

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.

Printing

lp
sends a file to the printer address under LPDEST.

Permissions

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.

Zipping / Unzipping

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.

Diffing and Versioning

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]).

Scripting Language Interpreters

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.

Compilers and Library Tools

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.

Disk Utilities

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.

GUI Applications

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.

Categories

Note: search one of these on this page to find an app.

GUI apps with Shortcuts

| Notes | Shortcut | Name | Comment | Categories | Exec |

Generator Script

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
su myuser -c "export DISPLAY=localhost:0.0; background_cmd &"
cat file1.txt file2.txt > file3.txt; mv file3.txt file2.txt # prepend one file onto another
ll -R # recursively do an ll command
rm -rf <dir> # remove a non-empty directory
pv *.tar.gz | tar -xz
tar -xvf file.tar.gz
tar -xvf file.tar.bz2
ln -s <target> <symbol>
. /etc/profile # shorthand for calling source, basically reloads the session
grep -r "text" <dir>
unlink <symbol>
ldd <executable> # list dependent libraries
chmod 664 <file(s)>
chmod 775 <directory>/
chmod u+x <script_name> # make a file executable
unzip file.zip -d folder # unzip a file to a folder
df -h # show disk space, human readable
du # instead run "baobab" for a gui version that's better
du -sh ./* # show folder's disk usage
mkdir -p path/to/make # make the directory for an entire path
tree -f | grep "GLOBALS" # show the full file path (and all symlinks) when listing files in a tree, and then search it
tree -d # only show directories, no files
top f -show columns
top j processor core
top <space> close
top i multicore info
top 1 list total core usages
htop
chgrp -R mygroup src # change a folder recursively to the RTSS group
> logfile.txt # truncate log file
xrdb ~/.Xdefaults
pound!/usr/bin/env bash #bash shebang
set -x # debugging bash scripts
set +x # no more debugging bash script
exec bash # clear all env variables
gdb /path/to/executable /path/to/core/dump type bt # how to analyze a core dump
gdb info locals
gdb bt full
git show --pretty="" --name-only HEAD # show the filenames only from a recent commit
git diff-tree --no-commit-id --name-only HEAD # same as above
git checkout SHA -- file # cherrypick an older version of a file in place
git show HEAD^:path/to/main.cpp > old_main.cpp # checkout an older version of a file to a new name
git log --name-only --oneline
git diff 15dc8^! # only show diff for a single commit
git diff --color-words
git diff --color-words=.
git diff --color-words='[^|]+' event_logger_cfg.txt | ansi2html.sh --bg=dark --palette=solarized > ~/rev2_diff.html
git difftool -y -x "colordiff -y -W $COLUMNS" | less -R # show output in columns
git diff --color HEAD^ HEAD -G"^[^\*#]" | ansi2html.sh > diff_report.html
git diff -G"^[^ \*#][^\*#]"
git diff -G'(^[^\*# ])|(^#\w)|(^\s+[^\*#])'
git diff --stat --color HEAD^ HEAD -G"^[^\*#]" | ansi2html.sh > diff_summary.html
git log --name-only --oneline #lists all the file changes, one line per file
git diff HEAD~15 #diff the working tree with the 15th previous commit
git diff HEAD~15 HEAD #diff last commit with the 15th previous commit
git difftool HEAD^ HEAD #show a diff between the current files and last commit
git status --porcelain | grep '^??' | cut -c4- >> .gitignore # ignore all untracked files
git ls-files -co --exclude-standard | grep '\.pic$' | xargs git add # add all of a type recursively to git
git difftool --cached
git log --name-only HEAD~5..HEAD --pretty=format:
ls -lrtd $(git status --porcelain | grep '^.[?M]' | sed 's/^.. //')
vim vim -S ~/session.vim
vim :mksession or :mks!
vim gf # go to file under cursor
vim Ctrl-^ # go to prev file
vim Ctrl-x,Ctrl-o # auto complete to (
vim Ctrl-x,Ctrl-l # auto complete to end of line
vim gd # go to definition
vim Ctrl-] # go to ctags definition
vim set number
vim set nonumber
vim Shift-V,<,.,.,. # Shift indentation left 4 times
vim Ctrl-V,Shift-I,# ,<ESC> # Comment out rows in python
vim Ctrl-S, Ctrl-Q # Lock and unlock scroll
vim :<line_strt>,<line_end>s/findtxt/replacetxt/g # replace all text between lines
vim :%!xxd # switch into hex
vim :%!xxd -r # exit from hex
vim :set tw=79 # hard text wrap at 79 characters
vim :set formatoptions+=t # required for the hard text wrap
vim :set tw=0 # undo hard text wrapping
vim :set list
vim :set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
when-changed -1 src/bash_script.bash -c "unbuffer shellcheck %f | head -n$(tput lines)"
python setup.py install --user
uname -a # Get the Linux version
ls -lR folder | grep ^l # list all symlinks and what they point to, recursively
grep "str" filename
grep -r -I --exclude-dir={.svn,useless_folder} "search_term" .
gunzip -c file.gz > file
timeout 5 unbuffer df -k | grep --line-buffered /mounted_folder | cut -c54-
grep -ohr -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' . # only show the ip addresses that come through
grep -n -c 3 -i "str" filename # list lines before and after found lines in file
grep -v "svn" # print lines not matching svn
symlinks -rv . # show all symlinks in a directory, recursively
pwd -P # show the actual path, not symbolic
qmake -r # recursively run qmake
qmake -query # list all the paths used by qmake
find . -type f -print0 | xargs -0 dos2unix
find . -maxdepth 1 -type f -exec mv {} old/ \;
find . -maxdepth 1 -type f -executable -delete
find -name "Makefile*" -delete # find and delete all variants of Makefile
find . -type f -mmin -120 # find files less than 2 hours old
find . -type f -mtime -1 # find files modified in the last day
find . -type f | perl -ne 'print $1 if m/\.([^.\/]+)$/' | sort -u # unique sorted list of types in directory
find . -type f -name "*.py" # find all of type
du -sh ./* | sort -h ; baobab #Human readable sort
sort -o file.txt file.txt # in place sort
sudo find . ! -user myuser -exec chown myuser:mygroup {} \;
find . -name '*condor*.pic' -exec cp --parents \{\} ../p4 \; # keep the folder structure when copying find results
echo "__" >> ~/.bashrc # append onto the end of bashrc
alias youralias='your cmd' # basic alias usage
alias disable alias by preceeding command with a backslash, ie \xterm
xterm -e "su - myuser" & # launch myuser properly in a new shell
rsync -avzhPCO local/path/to/u* user@remote:/remote/path/to/u*
rsync -azP /home/myuser/ myuser@remote:/home/myuser/
rsync -azP --exclude=var /home/myuser/ myuser@remote:/home/myuser/
rsync -a <source>/ <target>/ # copy into a non empty directory
rsync --dry-run -avh ./usr $HOME # archive, verbose, human readable, dry-run
history # list previous commands
history -c # clear list of commands
fc -l 10 # list last 10 commands
fc -l ssh # list last ssh command
make -j4 # use 4 jobs with make
tail -n +1 <filenames> # cat all the files with a heading line
tail -f <logfile> # keep an open feed to a file, showing appended lines
scp <filename> computer_name:/path/to/copy/to
svn diff -rPREV
svn cd $MYFOLDER/src
svn mkdir feature_a
svn cd feature_a
svn import <foldername> $SVN_HOST/<foldername>/trunk -m "Initial Import"
svn co $SVN_HOST/<foldername>/trunk <foldername>
lp -o landscape <filename> # print a file in landscape to nearby printer
firefox http://localhost:631/jobs/?WHICH_JOBS=completed&ORDER=dec&QUERY=myuser ... lp related
setterm -blink off
cat temp.txt | tee output.log # send output to both stderr, stdout, and a log file
cd - # goes to the previous directory
cd -P <symbolic_linked_directory> # jumps to full path of sym link
sudo comment_all_pcs_tabs.py -i *.pic
bang bang !! # run last command
bang cash !$ # reuse the last parameter
bang question mark !?string # reuse based on a wildcard start of the string
bang with tongue !****:p # only print the command, don't run it
rev <file name> # print out the reversed contents of filename
fortune -s # one sentence fortune
yes <string> # repeated string
figlet -f <font> <string> #
figlet fonts *.flf: banner big block bubble digital ivrit lean mini script shadow
sed -i -e 's/foo/bar/g' filename # replace foo with bar in place in filename
sed -i # in place
sed -e '<expression>' #command to run
sed 's//' # substitution
sed '//g' # global
./configure --prefix=$HOME # configure a package to install to the home directory
rpm2cpio <filename>.rpm | cpio -idmv
find . -name "*.rpm" -type f -print | xargs -I {} bash -c "echo {};rpm2cpio {} | cpio -idmv"
xargs -L 1
for i in ./*; do echo $i; done
find . -type f -exec my_command {} \;
xclip -o > helloworld.c # paste contents of clipboard to a file
wall "Message" # Writes to all a message aka broadcast...
script <session_log_file.txt> # store the entire session until exit
cat filename.txt | ansi2html.sh --bg=dark --palette=solarized > filename.html
cat <<HERE # How to use HEREDOC in bash and scripts
HERE
cat <<-HERE # Indented HEREDOC with tabs!
HERE
unbuffer colored_cmd | most
ps -ef | grep "process name"
pgrep "process name"
ps aux # show disowned processes
perl -0777 -pie 's/bar/baz' filename # in place find and replace like sed
perl ... ./Build install --install_base /home/username/usr # install to non-standard directory
getent passwd "username" | cut -d ':' -f 5 # print out a user's full name from unix username
symlinks -r .
find . -xtype l
echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- [email protected] # send email to someone with an attachment
var=${parameter:-defaultValue}
games bomber - bovo - kapman - katomic - kblackbox - kblocks - kbounce - kbreakout - kdiamond
games - kfourinline - kgoldrunner - killbots - kiriki - kjumpingcube - klines
games - kmahjongg - kmines - knetwalk - kolf - kollision - kpat - kreversi - sol
games - konquest - ksudoku - kubrick - lskat -
screen -d -m -S shared ---------- setup the shared session
screen -x shared ---------------- the screen clears and shows a new bash session now inside screen
export DISPLAY=localhost:0.0 ----- setup display properly for a screen session
date +%Y%m%d_%H%M%S # printout a timestamp for a filename that sorts in order nicely
(shopt -s dotglob; mv -- foo/* .) # move a directory up a level
== Miscellaneous Linux Commands ==
=== Introduction ===
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.
==== General Links ====
https://web.archive.org/web/20161121100913/http://archive.oreilly.com/linux/cmd/
http://explainshell.com/
And if it isn't on this page, of course, check Google, StackOverflow, and the man pages (RTFM = Read the Fine Manual).
=== Manual Lookup ===
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
=== Wildcards ===
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
=== Listing Files ===
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
=== Viewing Text ===
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.
=== Copy / Paste ===
XConfig needs to be configured properly for this to work:
- XSelection needs to be changed from `Clipboard` to `Primary`.
- 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`.
=== Text Editors ===
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+<key> 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+<key> or Alt+<Key> (short handed to C <key> and M <key>) for special interactions
gedit, kate, gvim, xemacs
graphical editors
=== Creating/Deleting Files and Folders ===
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)
=== Finding and Filtering Text ===
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
=== Bash Variables and Functions ===
$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.
=== Bash History ===
https://www.digitalocean.com/community/tutorials/how-to-use-bash-history-commands-and-expansions-on-a-linux-vps
!!
"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 <Ctrl><R> to search further back
=== Sessions ===
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)
=== Linking & Symlinks ===
ln -s
create a symbolic link, one file pointing to the actual file somewhere else on the harddrive
unlink
remove a symbolic link
=== Process Control ===
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
=== Other Users ===
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
=== Printing ===
lp
sends a file to the printer address under LPDEST
=== Permissions ===
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
=== Zipping / Unzipping ===
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
=== Diffing and Versioning ===
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])
=== Scripting Language Interpreters ===
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
=== Compilers and Library Tools ===
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
=== Disk Utilities ===
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
== GUI Applications ==
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.
=== Categories ===
Note: search one of these on this page to find an app
=== GUI apps with Shortcuts ===
|| Notes || Shortcut || Name || Comment || Categories || Exec ||
=== Generator Script ===
You can find these apps in the kickoff launcher in the corner of `plasma-desktop`.
Generate the table below
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment