Professional Documents
Culture Documents
Linux Basics: © Vijay Kumar, RC Bose Center of Cryptology and Security, Indian Statistical Institute, Kolkata, India
Linux Basics: © Vijay Kumar, RC Bose Center of Cryptology and Security, Indian Statistical Institute, Kolkata, India
A) GIT: Version Control System, really useful for tracking your changes.
TODO: try.github.com 15 mins tutorial.
B) Vi : Powerful Editor: Recommended to be used.
Useful commands to remember
:q - quit
:wq - Save and close
:syntax on - Turn on Syntax highlighting for C programming and other languages
:set number - Turn on the line numbers
TODO: 25-30 mins vimtutor
C) We learned different commands
a) whatis - provides a one line description of the commands
b) su : change users or become superuser: Remember the difference between su - <username> and
su <username>
c) touch - create zero byte files, mainly used for changing the timestamps of the file.
d) gcc -Wall -pedantic -g <C source file> -o <Executable file>
-Wall -pedantic : to check for all the warnings and errors if any.
-g to create the symbol file to be used by gdb
-o to create the executable file.
e) GDB: GNU debugger
gdb -tui <Program name>
-tui for listing the source while debugging
b <linenumber> to set the break point
p <variable name> to print the value of the variable
bt to print the stack call, mainly useful to find segmentation fault when multiple functions are
called.
f) make: If your program source file name is test.c, then you can directly write make test, this would
compile the test.c program. Remember this it's a faster way.
h) /etc/issue : Contains the message which is displayed on terminal before login.
i) /etc/motd: Contains the message which is displayed on terminal after login.
j) cal and date: Display calendar and date.
Remember the escapes sequences used in the /etc/issue. man agetty lists them.
TODO:
a) Do some work on all these commands,
b) read there man pages.
c) create one small program using vi with syntax on, compile it using gcc, try to debug it using gdb.,
try to track that program using git, upload them to a remote server, then pull your code, check if its
the same.
d) Try to change the messages before login, after login.
Vijay Kumar, RC Bose Center of Cryptology and Security, Indian Statistical Institute, Kolkata, India
Vijay Kumar, RC Bose Center of Cryptology and Security, Indian Statistical Institute, Kolkata, India
~/.bash_profile
~/.bash_history - contains all the history of the commands.
~/.bash_logout - contains the command which are executed when bash is exited
~/.bashrc
- setting of variables for bash.
/etc/profile
- setting of PATH variable and PS1
C) last, lastb, lastlog Vijay Kumar, RC Bose Center of Cryptology and Security, Indian Statistical Institute, Kolkata, India
last - shows all the login attempts and the reboot occurred.
lastb - shows all the bad login attempts
lastlog - shows the list of all the users and when did they login.
D)tar - tar archiving utility
-c create archive
-t list the content of the file
-x extract the files
-j bzip2 format
-z gzip format
E) Linux has six runlevels 0-6
Scripts are contained in /etc/rc[0-6,S].d/
Each folder contains the scripts which are followed by either K or S. If the first letter is K that script
is not executed. If S, that script is executed.
/etc/inittab contains the default run level.
F) pstree - Process tree
G) Sysctl - configure kernel parameters
/etc/sysctl.conf - contains the variables for kernel parameters.
sysctl -a display all the kernel parameters
sysctl -w <kernel parameter>
H) Kernel Modules
contained in /lib/modules/$(uname -r)/
lsmod - list all loaded modules
modprobe - load kernel modules
lspci - list all pci devices
lsusb - list all usb devices
hal-device - list all the Hardware Abstraction layer devices
I) mount and umount - Mount/unmount a filesystem
J) Groupadd, groupdel/ groupmod
-add, delete or modify any group
K) SUDO
/etc/sudoers
Vijay Kumar, RC Bose Center of Cryptology and Security, Indian Statistical Institute, Kolkata, India
Vijay Kumar, RC Bose Center of Cryptology and Security, Indian Statistical Institute, Kolkata, India