Unix SIG
https://tinyurl.com/rm7pskd
What is Unix, Linux etc.?
Many OS like MacOS/OSX and Ubuntu, have similar features to AT&T Unix. Hence called “Unix-like OS”.
Shell is the basic user interface. It may be graphical(GUI) or terminal interface.
Unix shell is the interface with ‘unix-like’ commands!
Bash is the language for the shell scripting. I.e, language to communicate with the “shell”.
Ubuntu is an operating system which is built on the Linux Kernel. It is based on Debian (another OS).
DistrOS is just the same as OS (or different versions of linux OS).
Difference between Unix and Linux
Today, “Linux” is used to refer to the whole GNU/Linux System.
2
Things to Note-
Commands are “CASE sensitiVe” in the command line.
GNOME Shell (GUI) on Ubuntu
Manpages
Use the man command wherever possible.
Start with man man !
If you already know the command and want to know it’s usage,
Check out tldr , you can install it by using
sudo apt install nodejs npm
sudo npm install -g tldr
(you could also use yarn)
To get a breakdown of the command checkout,
And paste the command in the search box!
3
Why use Linux and GNU software?
Some Notable Linux Software which are available on Windows,
4
Most windows applications can work on linux with the help of wine and playonlinux.
#JustAMeme
Some Basic CLI Commands/Tools
5
Piping will also be needed!
Install the following applications with
sudo apt install <pkgname>
Packages to install:
Flags
Examples-
6
Extra statements to the command that tell it what to do!
If man doesn’t work,
Try the ‘--help’ flag,
cat --help
Install the following applications with
sudo apt install <pkgname>
Packages to install:
tree
Prints a tree with all the files of a folder
ln
Creates a link to folder or file
Different customizations
7
You can start by getting a fancy color theme for your terminal on:
http://mayccoll.github.io/Gogh/
or search ‘gnome terminal gogh colors’
or,
bash -c "$(wget -qO- https://git.io/vQgMr)"
8
Nested Commands & Piping
fortune
Prints a random quote/proverb
compgen
Tries to match a word with a shell commands
cowsay
Ascii art of a cow saying the output
fzf
‘Fuzzy finder’ intended to search for files.
Gedit is the default “notepad”. You could also use “code” (VSCode) or “atom”(Atom) or vi!
Nautilus is the file manager.
apt
A terminal version of an app store. With features like searching, showing installed… etc.
less
Show output in easy scrollable format. (vi keys)
The ~/.bashrc configuration file
9
alias ls='ls --color=auto -A'
alias egrep='egrep --color=auto'
alias pullff=’git pull --rebase’
PS1='[\W]\$ ' #ezprompt.net/ or bashrcgenerator.com/
alias cls='clear && ls'
alias fm=’nautilus .’
alias fu=’sudo’
caf (){
cd “$@” && clear && ls
}
# Change some default bash options
shopt -s autocd
shopt -s cdspell
# Extend the PATH to include more directories with “:”
export PATH="$PATH:.yarn/bin:.npm-global/bin"
# Have a stegosaurus read out a quote whenever you open a terminal
fortune -s wisdom | cowsay -f stegosaurus
#neofetch
#curl wttr.in/pilani
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Aliases
# Bash Prompt
# Alias
# Alias for file manager
# Sometimes swear words work?
# Simple Function with”$@”
# autocomplete cd
# autocomplete filenames
Links, Variables
Configuration Files
10
Important Configuration files (in ~),
And for advanced system-wide configuration et cetera folder in root,
/etc
For a history of all your commands, see ~/.bash_history
For a fancy/powerful terminal,
For a fancy vim editor,
Vimium is an extremely efficient plugin on chrome!
For a fancy desktop,
Cool Scripts
11
mkcd(){
NAME=$@;
mkdir -p "$NAME";
cd "$NAME";
}
yt-music() {
# Get the title name
TITLE=$(youtube-dl --get-title --default-search ‘ytsearch’ \”$@\”)
cowsay “Now Playing - “$TITLE
# Play the Audio in vlc
vlc "$(youtube-dl --get-url --default-search 'ytsearch' \"$@\" | tail -1)"
}
Play Music From Youtube
Create folder and switch to it
searchit(){
thingtosearch=$@;
firefox --search $thingtosearch
}
Open search in firefox
Bash tricks
12
src: 10 bash tips
cut command
cut -d":" -f1,7 hello.txt
Cut with delimiter “:” and take the 1st and 7th fields of the file ‘hello.txt’
ls -l | cut -c 1
Take the output of “ls -l” and cut the first column.
Bash is CASE-sensitive (for commands) and space-sensitive.
Press “tab” to autocomplete a word!
More Command Line Tools
More CLI Tools recommended to learn,
13
find . -maxdepth 1 -type f | xargs wc -w
(print word count of all files in dir)
youtube-dl -x --audio-format mp3 --playlist-end 50 --autonumber-start 1 -o "%(title)s.%(ext)s"
(download playlist of songs from youtube)
Linux File System
14
Links
Understanding Tee
15
Search Results
Only Numbered Lines
www.website.com]
Sr. No. + Title
Same Output is Split
Final websites
Title Only
ddgr -n 8 --np hello world
grep ^.[0-9]
tee >( ___) |
cut -d ‘[‘ -f 2
cut -d ‘]‘ -f 1
sed ‘s/\[.*]$//’
cut -d ‘[‘ -f 1
sed ‘s/\]//’
cut -c 2-
There’s a shortcut and the answer lies in the meme on slide 1
Vim Keys:
% Run on current file
! Run command in shell
ddgr -n 8 --np nalanda bits pilani | grep ^.[0-9] | tee >( cut -d '[' -f2 | cut -d']' -f1 ) | cut -d '[' -f 1
Resources
Archwiki - List of Applications
A more complete Awesome List of unique and cool Apps for linux. From audio-visualizers to computational-biology software
An amazing beginner-level course to improve your basic productivity while programming.
This guide helps any beginner get acquainted with using Ubuntu more effectively.
Data Science at the Command Line
A slightly advanced usage of the command line for better efficiency as a data scientist.
16
If something goes wrong,
Summary
17
Always Check man, tldr or try the --help flag. You could also search it!
THANKS!
18
neofetch
Numix Square Icon Theme
Nordic GTK3 Theme
Checkout Slack: bitsacm.slack.com
Appendix - A view into the O.S.
Ubuntu - Build on Debian, Uses GNOME by default
Manjaro - Built on Archlinux, Choice of D.E.
Alternative Desktop Environments: xfce, mate, cinnamon...
19
Desktop Environment | GNOME(Ubuntu) | KDE | Some Alternatives |
Display Manager | GDM | KDM | LightDM |
Default File Manager | Nautilus | Dolphin | Thunar, pcmanfm |
Window Manager | (Gnome) | (KDE) | Openbox, i3, awesome |
Widget Toolkit | GTK | QT | Tk, kivy, wxwidget |
Component | Popular(Ubuntu) | Alternatives |
Bootloader | Grub | (few unimportant) |
Shell Scripting Language | Bash | Zsh, Fish |
Default Init System | Systemd | Runit |
Network Managers | NetworkManager | ConnMan, netctl |
Display Server | X.org (X11 Protocol) | Wayland Compositor (Wayland) |
Appendix - Search Script
20
gofetch(){
local optionno # Stores the option number
local output # Stores the output URL
local tempfile=$(mktemp) # Tempfile for storing output of tee
read -p "Search: " query # Take Input from terminal
# Get option no. selected after search
optionno=$(ddgr -x -n 8 --np $query | tee >(grep http.*:// >${tempfile} ) | grep ^.[0-9] | fzf -1 -0 --no-sort +m | cut -c 2)
# Test with cat ${tempfile}, echo $optionno
local N=0
while IFS= read -r line
do
if [ $((optionno - 1)) = $N ]
then
output="$line"
echo "$N = $line"
fi
let "N= $N + 1"
done < ${tempfile}
notify-send "Search results for Query: $query" # Send a notification that the search results are ready!
firefox --new-tab $output # Open the search result in a new tab
rm ${tempfile} # Delete tempfile
}
Searches the tempfile for the url with index ‘optionno’
Warning: It doesn’t always work… try finding test cases where it fails!
Appendix - Package Managers
21
O.S. | Package Manager |
Debian/Ubuntu | apt |
Mac | homebrew |
ArchLinux | pacman |
Windows | Chocolatey |
Language Specific | Package Manager |
Python | pip, anaconda |
NodeJS | yarn, npm |
Ruby | gems |
Lua | LuaRocks |
LaTex | tlmgr |
Rust | cargo |
Basic Operations -
(sometimes admin permissions ‘sudo’ are required for install/uninstall/update)
Debian Installer (not a package manager) | dpkg |