[Lecture 3] Introduction to Linux, Vim and Tmux
- Linux
- Linux
- Linux an open source operating system widely used based on UNIX(UNiplexed Information Computing System
(UNICS)).
- However Linux is completely independent of UNIX.
- History and philosophy of Linux
- Torvalds released the Linux kernel in September 1991. A community of developers worked to integrate
GNU components with Torvalds’ kernel to create a complete, free operating system known collectively
as Linux. Torvalds continues to develop the Linux kernel, currently at version 4.14, and a vast
developer community continues to create and integrate a wide range of components.
- Linux has adopted the copyleft stipulations of the Free Software Foundation which originated the
GNU GPL General Public License (GPL). Copyleft says that anything taken for free and modified
must, in turn, be distributed for free. In practice, if Linux or other GNU components are developed
or modified to create a new version of Linux, that new version must be distributed for free.
- Different Linux and preferences
- Ubuntu is one of the distribution(“distro”) of Linux
- A Linux distribution is an operating system made from a software collection that is based upon the
Linux kernel(the core of the Operating system) and, often, a package management system.
- Debian Based
- Debian and distributions based on it use the .deb package format and the dpkg package manager
and its frontends (such as apt-get or synaptic).
- Ubuntu
- Kali Linux
- other variants
- RPM Based
- .rpm package format
- Red Hat Linux
- Fedora
- Why developers like Linux/ we use Linux
-
https://www.cybrary.it/0p3n/programmers-prefer-linux-windows/
- Programmers love Linux because of its versatility, power, security and speed.
- Linux is open-source. At first this seems like a bad thing, because anyone can see the security bugs
in the kernel, and exploit them. However, this is counteracted by the fact that anyone can see
the bugs. This includes the people who fix the bugs. Because it’s open source, there are a lot
more people looking for, and fixing, bugs in the code. So as soon as a bug is spotted, it gets
fixed (most of the time). With Windows, the code is closed. So only the small team of developers
sees it, and not even all of the developers see all of the code. A bug can lurk around for years
before anyone realizes it’s there or realizes how to fix it.
- Structure of Linux and difference between Windows
- File extensions. Linux uses mime types
- Directory structure. Everything in linux is a file. An editable file
- In the Unix Way of Doing Things: everything is a file.
- A directory is one (of many) type of special file. It doesn’t contain data. Instead, it contains
pointers to all of the files that are contained within the directory.
- Remember, /proc/cpuinfo isn’t actually a text file containing this information – the Linux
kernel and the proc file system are exposing this information to us as a file. This allows
us to use familiar tools to view and work with the information.
- Case sensitivity in linux
- On Linux, the file system is case sensitive. This means that you could have files named file,
File, and FILE in the same folder. Each file would have different contents – Linux treats
capitalized letters and lower-case letters as different characters.
- Windows uses backslashes
- You Can Delete or Modify Open Files in Linux
- Concept of Root:
- Root is the highest level of anything in Linux. The root user which is the user with username
‘root’ is the user with the highest level of permission. The root directory is the highest
level of the directory (depicted by / ) in your system.
- What are users and groups in Linux
- Users:
- Linux is a multiuser operating system. In a multiuser environment, it is a common administration
task to create new users, modify existing users, or remove users.
- To see this list of users see the file /etc/passwd. You will see this the user accounts as
well you will notice the services have their own user accounts.
- Commands: adduser (adding a user), deluser (deleting a user)
- Groups:
- Think of the situation of a thousand users. Changing permissions of these users would be
tedious. That’s where the concept of group comes to rescue. In Linux you can create something
called groups. Then you can add users to that group and modify permission group-wise.
This makes life much easier. Eg: If we create each user of IMGians in one of our lab
computer. Then we might need groups like first_year, second_year, third_year, etc.
- The list of group is stored in a simple text file in /etc/group.
- Commands: usermod -G groupa,groupb user-name(add or delete a user from a group), getent group
group-name(see all members of a group)
- Using the terminal and basic commands
- What Exactly Are Commands?
- An executable program
- An alias
- Navigation
- Directory structure
- Tree like dir stucture like windows
- Storage devices are mounted in linux at different points unlike windows
- Unix systems have a single directory tree. All accessible storage must have an associated
location in this single directory tree. This is unlike Windows where (in the
most common syntax for file paths) there is one directory tree per storage component
(drive).
- Let’s say the CD-ROM device is /dev/cdrom and the chosen mount point is /media/cdrom
- File system exploration
- file, less
- less command loads page by page and is faster
- Manipulating files and dirs
- cp, mv, mkdir, rm, ln
- Difference between hard link and symbolic link
- Hard link may not reference a directory
- Symlink the better way of doing it. Contains a text pointer to the referenced file
- Unlike a hard link, a symbolic link does not contain the data in the target file. It
simply points to another entry somewhere in the file system.
- Also, when you delete a target file, symbolic links to that file become unusable,
whereas hard links preserve the contents of the file.
- man, whatis
- echo
- grep, sort, uniq, strings
- Permissions
- ls -al output explain
- Concept of . and …
- chmod
- Eg: “sudo chmod 777 filename.txt”
- Eg: “sudo chmod 775 foldername -R”
- chown
- Eg: “sudo chown <new_user> filename.txt”
- -R (for recursively for directories) add for director
- chgrp
- Eg: “sudo chgrp <new_grp> filename.txt”
- chgrp -R img_third directory
- Sudo and su
- ssh
- scp
- How ssh works?
- SSH, or Secure Shell, is a remote administration protocol that allows users to control and
modify their remote servers over the Internet. The service was created as a secure replacement
for the unencrypted Telnet and uses cryptographic techniques to ensure that all communication
to and from the remote server happens in an encrypted manner.
- ssh client and ssh daemon accepting connection
- .ssh/known_hosts etc.
- Demonstrate an example with doing it on .9 etc.
- ping, traceroute
- Share: The ping command is one of the most used utilities for troubleshooting, testing, and diagnosing
network connectivity issues. Ping works by sending one or more ICMP (Internet Control Message
Protocol) Echo Request packages to a specified destination IP on the network and waits for a
reply
- Vim
- Introduction
- Modes
- Command
- Basic Movement (h j k l 0 $ gg G :line_number)
- Cursor Movement (H L M)
- Page Movement (ctrl + U D E Y
- Word Movement (w e b)
- Number Powered (3 w)
- Insert
- Where you want to insert (i I a A o O )
- Number powered (3 i All esc)
- Visual
- V, v, ctrl+v
- Find
- Common search (F, f)
- When using (/ -> n, N)
- Next occurrence of the word (*, #)
- Matching parentheses (use %)
- Remove
- Using x and X
- Replace using r
- Delete
- Using d
- Also pastes the content
- yy - Yank (copy) the current line, including the newline character.
- yw - Yank (copy) the current line, including the newline character.
- p or P to paste
- Powerful (.)
- Vsp, sp
- Autocomplete
- undo, redo
- Tmux
- ctrl-b is the default prefix to the tell that this command is for tmux
- s list sessions (Then you can navigate to
- $ rename the current session
- d detach from the current session
- c create a new window
- , rename the current window
- w list windows
- % split horizontally
- " split vertically
- n change to the next window
- p change to the previous window
- 0 to 9 select windows 0 through