232623113-Basic-Linux-Commands.docx linux unix

mahakbhogill 44 views 12 slides Aug 02, 2024
Slide 1
Slide 1 of 12
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12

About This Presentation

command of linux and unix
Introduction

Overview of Linux/Unix
Importance of command-line interface
Basic Commands

pwd: Print working directory
ls: List directory contents
cd: Change directory
mkdir: Create directories
rmdir: Remove directories
touch: Create empty files


Slide Content

Basic Linux Commands

What is Linux
•Linux is a Unix system
•Free
•Open Source
•Developed by Linus Torvalds in 1991
•There are several Linux distributions:
–Red hat
–Fedora
–Ubantu

What is Linux Shell?
•Accepts your instruction or command
•If it is valid command, it is passed to
the kernel (part of the OS).
•Several shells available with Linux.
–BASH
•To find current shell type:
–$ echo $SHELL
•To know about command:
–Ex: man ls

Files and rights
•List your file
–$ ls
–$ ls –l
–$ ls –a
•Display entire file
–$ cat filename
•Copy
–$ cp filename1 filename2
•Move or change name
–$ mv filename1 filename2

Files and rights
•Remove file
–$ rm file_name
–$ rm -i
–$ rm –r
–$ rm -rf
•Display entire file
–$ cat file_name
•Copy
–$ cp file_name1 file_name2
•Change permissions
–$ chmod [options] file_name

Files and rights
•To change the rights, 2 methods with chmod:
•$ chmod o+r myfile, chmod g-rw myfile, chmod u=rw,go=r
myfile
•$ chmod 777 myfile, chmod 555 myfile
•Note: to change the rights on an entire directory:
•$ chmod –R 777 mydirectory, chmod -R g+rw.
•To change the owner: chown
–$ chown sumedh myfile

Directories and paths
•Make a new directory:
•$ mkdir dir_name
•“. “ is your current directory
•“..” is your upper level directory
•To Paths can be absolute or relative:
–/home/sumedh/bill/foo.txt is an absolute path.
–../bill/foo.txt is a relative path.

Directories and paths
•Change directory:
•$ cd dir_name
•$ cd ..
•$ cd or cd ~
•$ cd ~/bill = cd /home/sumedh/bill
•Current directory
•$ pwd
•Disk usage
•$ du file_name
•$ du -h

Job Control
•List your prcesses:
•$ top
•$ ps –ef
•$ ps –ef | grep jboss
•$ cd ~/bill = cd /home/sumedh/bill
•Kill a process
•$ kill [options] PID
•Ex: $ kill -9 624535
•Launch a job in background
•$ ./run.sh &

Miscellaneous
•Which user you have logged in:
•$ whoami
•Change the user:
•$ su – Sumdh_Kakde
•Date
•$ date
•Achieving : tar
•$ tar –cvzf archieve_name.tar dir_name/
•$ tar –xzvf archieve_name.tar or archieve_name.tar.gz
•File Compression:
•$ unzip test.zip

Miscellaneous
•Edit files:
•$ vi file_name.txt
•$ vim file_name.txt
•tail command:
•Print last 10 lines of the file by default
–$ tail file_name.txt
•Print last L number of lines from a file
–$ tail –n L file_name.txt
•View the contents of file in real time.
–$ tail –f log_file.log

Grep Command
https://www.geeksforgeeks.org/grep-command-in-unixlinux/