0% found this document useful (0 votes)
5 views5 pages

linux

The document outlines basic commands and functionalities of the Linux operating system, including memory management, process handling, file system operations, and hardware interactions. It provides examples of commonly used commands such as 'mkdir', 'rm', 'cp', 'mv', 'grep', and 'ssh', along with their syntax and usage. Additionally, it covers topics like process management, permissions, and remote connectivity in Linux.

Uploaded by

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

linux

The document outlines basic commands and functionalities of the Linux operating system, including memory management, process handling, file system operations, and hardware interactions. It provides examples of commonly used commands such as 'mkdir', 'rm', 'cp', 'mv', 'grep', and 'ssh', along with their syntax and usage. Additionally, it covers topics like process management, permissions, and remote connectivity in Linux.

Uploaded by

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

Basic Commanda:

there 4 main functions:

1)memory managemet
2)procees
3)file sysytem
4)Hardware

Linux is a multi user and multi tasking OS.

echo $SHELL -->to know which shell we are in


grep "Hyder" etc/passwd -->another command

bin ->bin directory contains all binar files


boot ->contains boot related files

pwd -> present working directory


ls - long listing files

man - gives details of command


ex : man ls

creating a folder(directory)
mkdir
syntax:
mkdir foldername
ex:
mkdir training
go into the folder
cd (change directory/folder)
ex:
cd training

remove a file
rm (remove)
ex:
rm display1.c
copy the file into another file
cp
Syntax:
cp source destination
ex:
cp display.c display1.c
this command will keep the source and copy into another file,
source and destination both exists.

mv (move)
syntax:
mv source destination
this command will rename source file to destination, hence
after this command execution, source will not exists

chmod -> to change permission


3. change the permissions like
chmod 777 file.csh
chown -->used to change ownership
sudo chwon Hyder:Hyder training

find:

search for testing.csh in my current directory/any other directories


Command: find
find command will search for a file

command:
find . -name testing.csh

grep:
search for a string in a folder/file:
ex:
search for "main" in my current folder
command : grep
ex:
grep "main" * (this command will search for a string "main" in all the files
in the current folder)

grep "main" testing.csh

Display the file names that matches the pattern : We can just display the files
that contains the given string/pattern.
$grep -l "unix" *
Show line number while displaying the output using grep -n : To show the line
number of file with the line matched.
$ grep -n "unix" geekfile.txt

grep -R "main" * it will search recursively in all directory

grep -i "Main" * (this command will search for a string "Main" in all the files in
the current folder after ignoring the case sensitivity)

egrep : used to serach more than 1 string at a time


egrep "key1|key"

df -->
to check for free disk space in all disks : df

du ->to check for space in pwd.

ps -> it will display the processes that are running

ps -aux ->it will dispaly the process of particular user


x=user name

ps - (Process Status) - It reports a snapshot of current processes.


top (Table Of Processes) - is a task manager program displays information about CPU
and memory utilization.

kill -> to kill the running processes


ex:
kill -9 processid
kill -9 213

kill -15 is the safe and correct way of terminating a process. It's equivalent to
safely shutting down a computer.

kill -9 is the unsafe way of brutally murdering a process.

cat --> to show content of particualr file

cat file3.txt

head:
it will print from top
cat testcut.txt | head -n 2 (this command will print first 2 lines from the
testcut.txt file)

tail command:
tail -n 1 testcut.txt
cat testcut.txt | tail -n 1
this command will print the last line of the testcut.txt file

diff -->knows the diffrent of 2 files

VIM---

Vi editor

vi commands
vi is a editor in unix/linux
this editor will work in 2 modes:
1. insertion mode
2. esc mode

1. insertion mode: (i)


if you want to edit/type then we need to use this mode
2. esc mode (esc button)
Where you can execute some commands
-> delete a character (x)
-> delete a word (dw)
-> delete a line (dd)
-> delete multiple line (5 dd or 10 dd or 20dd)
-> go to the begining of the file (:1)
-> go to the end of the file (:$)
-> set nu (setting line numbers)
-> save a file (:w)
-> save and quit (:wq!)

yy ->to copy full line and store in buffer and press key to paste it

10 yy --> to copy 10 lines

/ ->to search string from top


/hyder

? -->to search from bottom


?hyder
to replace string

For example, to search for the first occurrence of the string ‘foo’ in the current
line and replace it with ‘bar’, you would use:
:s/foo/bar/

To replace all occurrences of the search pattern in the current line, add the g
flag:
:s/foo/bar/g

If you want to search and replace the pattern in the entire file, use the
percentage character % as a range.
This character indicates a range from the first to the last line of the file:
:%s/foo/bar/g

:set nu -> to set line number

Linux Remote connectivtity:

ssh
scp
telnet
putty

which command is used to access system from another linux server?(to connect
remotley)
ssh
defual port is 22
ssh (Secure shell)bcs communication between host and client in encrypted format.

we can also use telnet command but it's not secures but ssh is secured.
defual port is 23

scp command is used to copy file.

Linux OS.

Shell it's a nothing but interface between user and kernal


linux provide lot's of command for process, file.

System call is we are going to get the service from kernal.sysytem call is a
gateway get enter into kernal.
each module present in kernal there will be system call , for process, file ,
device management etc.

process memory map


->stack
->heap
->data
->text

process states.
start -> ready ->running ->exit

when we run program in linux os it create a child process.

inter process communication(IPC)


->message passing
-> shared memory
-> signal

You might also like