Linux's Terminal is much more powerful when compared to Windows' Command Prompt
As a Linux user, one would need to spend a lot of time on the Terminal. "Typing" feels a lot more like a programmer when compared to "Clicking"
http://ranveeraggarwal.com/blog/ubuntu-windows-dual-boot
Type the following commands one by one :-
The following commands are used to open files and folders respectively. Make sure the file exists in that directory. Sublime Text will create it otherwise.
sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text
subl filename.py
subl .
Type the following command to install it and get started :-
It should be installed by default. Vim is rather daunting at first. Do look at this guide to get started :-
http://www.engadget.com/2012/07/10/vim-how-to/
sudo apt-get install vim
vim filename.py
Use the following guide to install Android Studio :-
https://developer.android.com/sdk/installing/index.html?pkg=studio
You might have to make studio.sh an executable and then run it. Do the following for the same :-
sudo chmod 777 studio.sh
./studio.sh
LAMP Server :- http://www.prateekchandan.me/how-to-setup-localhost
Arduino :-
Laravel :- https://laracasts.com/series/laravel-5-fundamentals/episodes/1
Install PHP-mcrypt too
Gimp / Geogebra :-
sudo apt-get update
sudo apt-get install arduino arduino-core
sudo apt-get install mcrypt
sudo apt-get install gimp
sudo apt-get install geogebra
Python OpenCV :- https://help.ubuntu.com/community/OpenCV
Processing :- https://www.processing.org/tutorials/gettingstarted/
~ represents the home directory.
ls List all files in a directory.
cd Downloads Change directory to Downloads
cd .. Go one directory behind
/ Root folder
Press Tab to auto-complete the directory / file name.
kalpesh@kalpesh-Inspiron-3542:~$ ls
sudo "super do", makes you master in short.
apt-get The package manager of Ubuntu
update Listing of changes in repositories. It doesn't actually download the repositories.
kalpesh@kalpesh-Inspiron-3542:~$ sudo apt-get update
kalpesh@kalpesh-Inspiron-3542:~$ sudo apt-get install geogebra
mv - Move file
rm - Remove file
cp - Copy file
kalpesh@kalpesh-Inspiron-3542:~$ mkdir sample
kalpesh@kalpesh-Inspiron-3542:~$ cp test.cpp sample/test.cpp
kalpesh@kalpesh-Inspiron-3542:~$ cd sample
kalpesh@kalpesh-Inspiron-3542:~/sample$ ls
test.cpp
kalpesh@kalpesh-Inspiron-3542:~/sample$ mv test.cpp xyz.cpp
kalpesh@kalpesh-Inspiron-3542:~/sample$ ls
xyz.cpp
kalpesh@kalpesh-Inspiron-3542:~/sample$ rm test.cpp
rm: cannot remove ‘test.cpp’: No such file or directory
kalpesh@kalpesh-Inspiron-3542:~/sample$ rm xyz.cpp
kalpesh@kalpesh-Inspiron-3542:~/sample$ ls
kalpesh@kalpesh-Inspiron-3542:~/sample$
man <command> - A good way to learn about Unix commands, especially to get details on flags and parameters.
Alternatively, you could learn about commands with the --help flag, or by simply typing the command.
You may use a -v or --version flag to obtain the version for the utility.
chmod Command to change file permissions
777 New file permissions
./run.sh Execute file run.sh
kalpesh@kalpesh-Inspiron-3542:~/sample$ subl run.sh
kalpesh@kalpesh-Inspiron-3542:~/sample$ ./run.sh
bash: ./run.sh: Permission denied
kalpesh@kalpesh-Inspiron-3542:~/sample$ sudo chmod 777 run.sh
[sudo] password for kalpesh:
kalpesh@kalpesh-Inspiron-3542:~/sample$ ls
run.sh
kalpesh@kalpesh-Inspiron-3542:~/sample$ ./run.sh
kalpesh@kalpesh-Inspiron-3542:~/sample$
chmod follows the following number code :-
The three 7's represent the following :-
u - user
g - group
o - other
r - read, w-write, x-execute
kalpesh@kalpesh-Inspiron-3542:~/sample$ subl run.sh
kalpesh@kalpesh-Inspiron-3542:~/sample$ ./run.sh
bash: ./run.sh: Permission denied
kalpesh@kalpesh-Inspiron-3542:~/sample$ sudo chmod u=rwx,g=rwx,o=rwx run.sh
[sudo] password for kalpesh:
kalpesh@kalpesh-Inspiron-3542:~/sample$ ls
run.sh
kalpesh@kalpesh-Inspiron-3542:~/sample$ ./run.sh
kalpesh@kalpesh-Inspiron-3542:~/sample$
wget Simply downloads the file off the network.
kalpesh@kalpesh-Inspiron-3542:~/sample$ sudo apt-get install wget
.
.
kalpesh@kalpesh-Inspiron-3542:~/sample$ wget files.explosm.net/comics/Rob/feel-great2.png
All paths start from the root folder.
Editing, adding files here are essential for any programmer. You might often get a "Permission Denied" error while doing so.
su Super user
# represents su mode
exit A command within su to exit super user mode.
kalpesh@kalpesh-Inspiron-3542:~$ sudo su
[sudo] password for kalpesh:
root@kalpesh-Inspiron-3542:/home/kalpesh# exit
exit
kalpesh@kalpesh-Inspiron-3542:~$
root@kalpesh-Inspiron-3542:/home/kalpesh# find -name "CS101*"
./CS101 Project
./CS101 Videos
root@kalpesh-Inspiron-3542:/home/kalpesh#
root@kalpesh-Inspiron-3542:/home/kalpesh# find -name "*.ogv"
.
.
./CS101 Videos/2.ogv
./CS101 Videos/video1-6.ogv
./CS101 Videos/1.ogv
top displays the list of processes running on the PC.
kalpesh@kalpesh-Inspiron-3542:~$ top
top - 17:55:01 up 3 days, 23:06, 2 users, load average: 0.22, 0.42, 0.54
Tasks: 241 total, 3 running, 238 sleeping, 0 stopped, 0 zombie
%Cpu(s): 3.8 us, 0.8 sy, 0.2 ni, 93.8 id, 1.4 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 3950144 total, 3643452 used, 306692 free, 50056 buffers
KiB Swap: 9764860 total, 549344 used, 9215516 free. 899724 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1449 root 20 0 423968 45196 31648 S 3.3 1.1 91:34.25 Xorg
1944 kalpesh 20 0 1585324 102952 20916 S 2.7 2.6 105:28.78 compiz
3437 kalpesh 20 0 692800 22368 12372 S 2.7 0.6 0:04.20 gnome-term+
30971 kalpesh 20 0 1058944 248412 23964 S 2.7 6.3 14:34.22 chrome
2257 kalpesh 20 0 1787144 191548 40752 S 2.3 4.8 140:50.06 chrome
12174 kalpesh 20 0 1115032 286936 23920 S 1.7 7.3 3:37.80 chrome
18430 kalpesh 20 0 1142680 320316 25092 S 1.7 8.1 0:40.95 chrome
368 root -51 0 0 0 0 S 1.0 0.0 6:50.69 irq/39-DLL+
18846 kalpesh 20 0 825392 91484 23408 S 1.0 2.3 0:03.51 chrome
2374 kalpesh 20 0 842412 92908 9112 S 0.7 2.4 19:21.30 chrome
458 root 20 0 0 0 0 S 0.3 0.0 2:34.79 rts5139-po+
2055 kalpesh 20 0 20496 352 232 S 0.3 0.0 1:04.38 syndaemon
17889 kalpesh 20 0 1206188 254540 23992 S 0.3 6.4 41:49.72 chrome
18010 root 20 0 0 0 0 S 0.3 0.0 0:02.93 kworker/u8+
1 root 20 0 33904 2112 768 S 0.0 0.1 0:04.22 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.09 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:17.40 ksoftirqd/0
cat swag.cpp
cat >swag.cpp
What will happen if we get if, for, switch and all the CS101 stuff into commands?
Magic.
The answer is Shell Scripting.
kalpesh@kalpesh-Inspiron-3542:~/sample$ ./run.sh
Let's make a small shell script using the things we have learnt.
Type the following in a text editor :-
The script automates the download of 24 gif images off MIT OCW. We could do the same for the videos by replacing ".gif" with ".mp4"
#!/bin/bash
COUNT=24
while [ $COUNT -gt 0 ]; do
wget http://ia902706.us.archive.org/6/items/MIT6.006F11/MIT6_006F11_lec"$COUNT"_300k.gif
let COUNT=COUNT-1
done
This script is a little more advanced.
Here we are taking a number input as a command line argument. We could get the same via voice/image processing.
var=$(gsettings get com.canonical.Unity.Launcher favorites)
let counter=-1
declare -a ARRAY
const1=0
for i in $var; do
if [ ${#i} -gt 23 ]; then
let counter=counter+1
var2=${#i}
let var2=var2-17
#echo $var2
if [ $counter -eq $const1 ]; then
let var2=var2-1
ARRAY[$counter]=${i:16:var2}
else
ARRAY[$counter]=${i:15:var2}
fi
else
sleep 0;
fi
done
cd /
file_to_open=$1
let file_to_open=file_to_open-1
echo ${ARRAY[$file_to_open]}
`grep '^Exec' /usr/share/applications/${ARRAY[$file_to_open]} | tail -1 | sed 's/^Exec=//' | sed 's/%.//'` &