0% found this document useful (0 votes)
55 views7 pages

Day 1 Assignment

The document provides an introduction to Linux fundamentals covering differences between Linux and Unix, run levels in Linux and how to change them using init and systemctl commands, importance of the GNU project, Linux file permissions, vi editor tools for encrypting files and creating C/C++ templates, tag navigation in vi editor using ctags, and an overview of the GNU compiler collection (GCC) and common GCC optimization patterns.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views7 pages

Day 1 Assignment

The document provides an introduction to Linux fundamentals covering differences between Linux and Unix, run levels in Linux and how to change them using init and systemctl commands, importance of the GNU project, Linux file permissions, vi editor tools for encrypting files and creating C/C++ templates, tag navigation in vi editor using ctags, and an overview of the GNU compiler collection (GCC) and common GCC optimization patterns.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

LINUX FUNDAMENTALS

DAY 1
INTRODUCTION TO LINUX
1. How different is LINUX when compared with Unix?
Linux is open source and is developed by Linux community of developers. Unix was
developed by AT&T Bell labs and is not open source.

Linux is used in wide varieties from desktop, servers, smartphones to mainframes. Unix is
mostly used on servers, workstations or PCs.

2. What are the run levels in Linux and how to change them?
Run Levels:

➢ Run Level 0 is shutdown position. Linux system is powered off. Linux systems run
levels transitioned to 0 to shut down.
➢ Run Level 1 is single-user mode there is no network and used rarely.
➢ Run Level 2 is multi-user mode but there is no network file system. This level is used
rarely too.
➢ Run Level 3 is the default mode for most of the Linux servers. There is no gui but all
other services and features are functional.
➢ Run Level 4 is user-defined.
➢ Run Level 5 is a multi-user GUI mode default for most of the user systems.
➢ Run Level 6 is used to reboot the system.
How To Change Run Level
Run levels can be changed easily. To change run level root privilege is required.
$ init 3
This will change the current run level to run level 3
Boot With Run Level 6
We can reboot Linux system by changing to run level 6 like below
$ init 6
This is the same as reboot command
Run Level With Systemctl
In the old days, init was the ruler of the run levels. But times have changed. Now systemctl is
the emperor. All most all run-level related operations are done with systemctl.
Get Current Run Level With Systemctl
We can get the current run level with systemctl like below
$ systemctl get-default
multi-user.target
• As you guess multi.user is equal to run level 3
Change Run Level With Systemctl
We can change run level with systemctl by providing systemctl targets like below
$ systemctl isolate graphical.target
• isolate parameters change the run level to graphical.target
Set Default Run Level With Systemctl
We can set default run level with systemctl. Default run level is start when the computer boot.
We want to not start GUI we can change the default run level to multi-user.target like below
$ systemctl set-default multi-user.target
3. what is the importance of the GNU project?
Its goal is to give computer users freedom and control in their use of their computers and
computing devices by collaboratively developing and publishing software that gives everyone
the rights to freely run the software, copy and distribute it, study it, and modify it. GNU
software grants these rights in its license.
4. What are file permission groups in linux? explain each of them?
All the three owners (user owner, group, others) in the Linux system have three types of
permissions defined. Nine characters denotes the three types of permissions.
1. Read (r) : The read permission allows you to open and read the content of a file. But
you can't do any editing or modification in the file.
2. Write (w) : The write permission allows you to edit, remove or rename a file. For
instance, if a file is present in a directory, and write permission is set on the file but not
on the directory, then you can edit the content of the file but can't remove, or rename it.
3. Execute (x): In Unix type system, you can't run or execute a program unless execute
permission is set.But in Windows, there is no such permission available.
TOOLS
VI EDITOR
1. How to encrypt files using vi editor in Linux ? explain and write a
syntax for it.

We have to create a file by the filename (eg. vi filename)

Open the file , type the content and set number to the content (eg: se nu)
Then type X and press enter

NOTE: X is upper case

Vi will prompt for an encryption key


Enter any key and press entry

It will prompt for confirmation of the key, enter the same key again

If we give wrong key, then file is not prompt for confirmation

2. Create a C and C++ template in vi in Linux.


Step 1: Download C Vim Plugin

Step 2: Install the C Vim Plugin

Step 3: Enable the plugin in the ~/.vimrc


Add the following line to the ~/.vimrc to enable the plugin for Vim editor.
3. Write a syntax for Tag navigation in vi editor? And explain the use of
find command to create ctags (for code navigation).

Tag navigation in vi editor

1. Jump to a tag: Ctrl + ] .


2. Jump back: Ctrl + O .
3. Jump to a tag again: Ctrl + I .

ctags (for code navigation).


ctags command in Linux system is used for the with the classic editors. It allows quick access
across the files (For example quickly seeing definition of a function). A user can run tags or
ctags inside a directory to create a simple index of the source files while working on.

ctags [options] [file(s)]

The find command in UNIX is a command line utility for walking a file hierarchy. It can be
used to find files and directories and perform subsequent operations on them. Yet using it to
create ctags is done only in case of code navigation.

find . -name '*.[chsS]' | xargs etags –

here the star can be interpreted as a wildcard. So enclosing the name in single -quotes so the
shell wont interpret.

GCC

4. What do you understand by GNU compiler? Explain the common GCC


patterns and use of GCC optimizer?
The GNU Compiler Collection (GCC) is an optimizing compiler produced by the GNU Project
supporting various programming languages, hardware architectures and operating systems. ...
GCC is a key component of the GNU toolchain and the standard compiler for most projects
related to GNU and the Linux kernel.
GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff.
It also enables -finline-functions, causes the compiler to tune for code size rather than
execution speed, and performs further optimizations designed to reduce code size.

You might also like