0% found this document useful (0 votes)
17 views9 pages

Linux Lesson 1

The document discusses Linux operating systems and commands. It provides information on what Linux is, the benefits of Linux like free and open source applications, and commands for navigating files systems, editing text, and checking system information.

Uploaded by

githusidney
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views9 pages

Linux Lesson 1

The document discusses Linux operating systems and commands. It provides information on what Linux is, the benefits of Linux like free and open source applications, and commands for navigating files systems, editing text, and checking system information.

Uploaded by

githusidney
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Linux operating system which was developed through a cooperation of numerous people around the

world is free and accessible by everyone in the world(open-source).

What is good about linux

Linux has a rich collection of applications which are free and commercial as well as a lare variety of
tools ,graphical ,word processing ,networking ,security and administration

Another aspect of l is its appeal to users is the amazing range of peripheral that is supported and the
speed is at which the ….

Is also important to users Is the amount of software that is available, not just source code but also
rebuilt binaries that are easy to install and easy to run.

Linux supports programs called ….that run code intended for other systems

A virtual machine appears to the user and the software running it as a completely physical machine.
The Slash is followed by the name of the file located in the file directory. An Absolute path name can
continue tracing a path through all intermediate intermediatory to the file identified by the path name.

Relative path name traces a path a from the working directory to a file. The path is relative to the
working directory ,any path name that does not begin with the root directory is a relative path name.

777

711 Owner can read,write and execute files.Groups


and others can execute files
644 Owner can read and write file ,Group and others
can read file.
640 Owner can read and write file.Group can read
file,Others cannot access file.
R -4

w- 2

x–1

LINUX COMMANDS

Mkdir – Create new directory

Touch file_name – Creates a file

Cd – change to directory

Cat – displays the contents of a file

Creates and text to the file

Ls – lists files

Head – Displays the first 10 lines of a file

Tail – Displays the last 10 lines of a file

Tac- Dsplays the files content in reverse

More – Displays Large Content

Id – displays the user id of the User

Ls – la

Grep – filer to search a given paatern in a file

e.g grep Linux file1.txt – searches the name Linux in the file1.txt

Ping – diplays the network connectivity

History – Displays the history of the commands inserted before

Hostname –
Hostname -I – Dislays the Ip Address of the host

Chmod – change the users permssions

Nl – dipalys the line numbers

Wc – give number of lines ,words and the characters of the file content

Uniq – removes duplicate of the file content

Less – displays contents of a file that are large

Ls / - Displays the directories

Rmdir-r > removes the directory and the files inside

Cp – Copy

Mv – Move,Rename

Grep .name.file. – Searches the name in the file

Cat - command when u press the cat command ,it will duplicate the script/text written inside until
pressed Ctrl +D

Vi – Text Editor

e.g Vi File_name

Press I to insert

After insert ,press esc then :wq enter

05.03.2023

Example 1

Vi stationary
2000,Sheet letter head ordered
Vi Tapes
1 Box measuring tape ordered
Vi Pens
12 Dozen Black Pens Ordered
Cat Stationary
Cat Tapes
Cat Pens
Cat Stationary tapes pens > Supply-ordered

Example 2
Date
Date > whoson
w>>whoson (w: Displays information about the users who are currently logged in.)
Cat whoson

Touch – To create a file e.g Touch temp


Example 3
Touch temp
Set -o noclobber – used to prevent accidental overwriting of files
Echo “Hii There”>temp
Example 4
Vi orange
This is an orange
Vi pear
This is a pear
Cat orange
Cat pear >>orange - adds content of file pear to file orange
Cat orange
Example 5
Vi whoson
Date
Echo “Users currently Logged in”
W
:wq

Cat whoson
./whoson

Ls -l whoson
Drw-
Chmod 777 whoson
Ls -l whoseon
Drw-
./whoseon
SCRIPTS
Example
vi bash_script
#!bin/bash
Echo”This is a bash script”
:wq

Cat bash_script
./bash_script

Vi perl-script- Pl
#!/bin/perl -w
Print(this is a perl script)
Vi tcsh_script
#!/bin/tcsh
Echo”this is a tcsh script”
Set person =zach

1. Echo”person is $person”
#!/bin/tesh: This is called the shebang line, which specifies the path to the
interpreter that will execute the script. In this case, it points to /bin/tesh,
indicating that this script is intended to be executed using the tcsh shell.
2. Echo "this is a tcsh script" : This line simply prints the text "this is a tcsh script" to
the standard output.
3. Set person = zach: This line declares a variable named person and assigns the value
"zach" to it. In tcsh, the set command is used to assign values to variables.
4. Echo "person is $person": This line prints the text "person is " followed by the value
of the person variable. In tcsh, variable values are accessed using the $ prefix.

So, when you execute this script, it will print the specified messages to the standard
output, indicating that it's a tcsh script and displaying the value of the person variable
as "zach". However, it's worth noting that there's a typo in the shebang line ( #!/bin/tesh),
as it should likely be #!/bin/tcsh instead of #!/bin/tesh, assuming that tcsh is the correct
shell interpreter

df Command:
The df or disk-free command shows the used and the available disk space. You can
use the additional options to check disk space differently. For instance, you can use
the df -h command to check the disk usage in the human-readable format.

12/03/2024

Ps – f – lists all the users …

true|| false && false


echo $? – 1

false && false || true


echo $? – 0

(true||false) && false


echo $? – 1

false && (false || true)


echo $? – 1

person=max

echo person

echo $person

person=”Max and Zach”

echo $person
echo “$person”

declare – r

declare – l

locale command

echo $lang

locale – av

peron=”Max and Zach “

echo $person

eco “$person”

T2=EST+SEDT date

T2=America/Newyork date

Pstree- p

Hash – displays commands used in previous

History – all commands inserted

Hash – r . it deletes the commands used

Fc – 1

bz

bzc

FUNCTIONS

say_hii () [ echo “hii”;]

say-hii

hii

function whoson{

date
echo “who is concathy the lst”
w

demo(){

x=4
local y=8

echo “demo:&x &y “

echo {4..8}

echo {8..16..2}

echo {a..m..3}

seq 4 8

seq -sl 8 16 2

vi age-check

read – p”How old are you” age

echo “Wow in $((100-age)),you will be 100 years “

:wq

Cat age-check

./age-check

It seems you've provided a mix of commands, expressions, and function definitions in your question.
Let's categorize and explain them:

### Commands:

1. `ps -f`: This command lists all processes in a full-format listing.

2. `echo $?`: This command prints the exit status of the last executed command. `$?` holds the exit
status of the most recently executed foreground pipeline.

3. `locale`: This command displays information about the current locale settings.

4. `locale -av`: This command lists all available locales.

5. `pstree -p`: This command displays a tree diagram of running processes.


6. `history`: This command displays a list of previously executed commands.

7. `hash -r`: This command resets the command hash table.

8. `fc -l`: This command lists previously executed commands.

### Shell Expressions:

1. `true || false && false`: This expression evaluates to `true` because the first condition (`true`) is true.
The `&&` operator will only evaluate the second expression if the first one is true, but it doesn't matter
because the result is already determined.

2. `false && false || true`: This expression evaluates to `true` because the last condition (`true`) is true.
The `&&` operator short-circuits when the first expression is false, so the second expression isn't
evaluated.

3. `(true || false) && false`: This expression evaluates to `false` because the last condition (`false`) is
false.

4. `false && (false || true)`: This expression evaluates to `false` because the last condition (`false ||
true`) is true, but the first condition (`false`) is false.

### Variable Manipulations:

1. `person=max`: This assigns the string "max" to the variable `person`.

2. `person="Max and Zach"`: This assigns the string "Max and Zach" to the variable `person`.

### Functions:

1. `say_hii () { echo "hii"; }`: Defines a function named `say_hii` that echoes "hii".

2. `demo() { ... }`: Defines a function named `demo` that sets variables `x` and `y`, echoes their values,
and demonstrates brace expansion and sequence generation.
3. `whoson() { ... }`: Defines a function named `whoson` that prints the current date and time and
echoes "who is concathy the lst" followed by the output of the `w` command.

4. `age-check`: Opens a file named `age-check` in the `vi` editor, prompting the user to input their age
and then prints a message about their age.

### Miscellaneous:

- `T2=EST+SEDT date`: This attempts to set the `T2` environment variable to the string "EST+SEDT"
before running the `date` command. However, it won't work as intended because the `date` command
expects a specific format for setting time zones.

- `T2=America/New_York date`: This attempts to set the `T2` environment variable to the time zone
"America/New_York" before running the `date` command. This will display the current date and time
in the specified time zone.

- `./age-check`: This attempts to execute the `age-check` script (if it's executable) in the current
directory.

- `bzc`: This seems to be a typo or an incomplete command.

These are the meanings and categorizations of the commands and expressions you provided. Let me
know if you need further clarification on any specific part!

Journalctl – viewing systems log

Write a regular expression to match a quoted string like “He said ,”Go get me the wrench ,”but I didn’t
hear him” using a regular expression

Answ – “.*?”

You might also like