Linux Lesson 1
Linux Lesson 1
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
w- 2
x–1
LINUX COMMANDS
Cd – change to directory
Ls – lists files
Ls – la
e.g grep Linux file1.txt – searches the name Linux in the file1.txt
Hostname –
Hostname -I – Dislays the Ip Address of the host
Wc – give number of lines ,words and the characters of the file content
Cp – Copy
Mv – Move,Rename
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
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
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
person=max
echo person
echo $person
echo $person
echo “$person”
declare – r
declare – l
locale command
echo $lang
locale – av
echo $person
eco “$person”
T2=EST+SEDT date
T2=America/Newyork date
Pstree- p
Fc – 1
bz
bzc
FUNCTIONS
say-hii
hii
function whoson{
date
echo “who is concathy the lst”
w
demo(){
x=4
local y=8
echo {4..8}
echo {8..16..2}
echo {a..m..3}
seq 4 8
seq -sl 8 16 2
vi age-check
: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:
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.
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.
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.
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!
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 – “.*?”