You are on page 1of 4

ses:-04/05/2022

commands:-

difference betwen windows and cygwin?


windows cygwin(linux)
1. files, folders, drives files, directory
2. os cygwin is an interface for windows to
use linux commands
3. user path user path
C:\Users\Koushik /home/Koushik

1. pwd
2. mkdir
create a directory
mkdir dir_name

mkdir <dir_path>/dir_name

Q. being in user path create a directory of name dir1 in path D:/unix_april/


Ans:-
mkdir /cygdrive/d/unix_april/dir1

o parent directory command:-


mkdir -p <dir_path>/dir_name
or
mkdir -p dir_name

example:-
mkdir -p a/b/c/d

Q. step1:-
using mkdir command create a directory called as example
step2:-
in example using parent directory command create directory as
-INDIA
-KARNATAKA
-
BANGALORE

-HEBBAL

Ans:-
mkdir -p INDIA/KARNATAKA/BANGALORE/HEBBAL

3. ls
-l
long listing format
-t
sort based on modification time(newest first)
-r
reverse order sorting
-a
list all contents of cuurent dir(even the hidden files)
-h
display the size of files in human readable format

example:-
ls -ltrha

4. cd
cd [change directory]
cd . -> be in the current directory itself
cd .. or cd ../ -> go to previous directory
cd ~ or cd -> go to root directory or user path

Q. my pwd ->

cygdrive/d/PERSONAL/NOTES/SYSTEM_VERILOG/1.APB_MEMORY/mem_tb_development
I want to go 4 steps backward what is the command to be used.

Ans:- cd ../../../../ -> correct


cd ../../../.. -> correct

cd ........ -> is this possible -> NOT possible

5. touch
create a file of any extension

touch filename.extension
//creates a file in current directory itself

touch <dir_path>/filename.extension

touch <dir_path_1>/filename_1.extension <dir_path_2>/filename_2.extension so


on...

Q. my present working directory is


$ pwd
/cygdrive/d
i want to create a file by name full_adder.v in dir_path
/cygdrive/d/unix_april/dir1/lab_session

Ans:-
touch /cygdrive/d/unix_april/dir1/lab_session/full_adder.v
or
touch unix_april/dir1/lab_session/full_adder.v

Q. my present working directory is


$ pwd
/cygdrive/d
i want to create a file by name full_sub.v in dir_path
/cygdrive/d/unix_april/dir1/lab_session
i want to create a file by name half_sub.v in dir_path
/cygdrive/d/unix_april/dir1/a/b/c/d/

Ans:-
touch unix_april/dir1/lab_session/full_sub.v
unix_april/dir1/a/b/c/d/half_sub.v

Q. create multiple files in same directory

Ans:-
touch /cygdrive/d/unix_april/dir1/abc.txt
/cygdrive/d/unix_april/dir1/xyz.txt
or
touch 1.txt 2.txt 3.txt 4.txt

o cat
display the entire file content on to the terminal

cat filename.ext
-n to display line numbers

cat > filename.txt

example:-
$ cat -n full_adder.v half_adder.v full_sub.v
1 module
2 //this is a full_adder.v file
3 endmodule
4 module
5 //this is a half_adder.v file
6
7 endmodule
8 module
9 //this is a full_sub.v file
10
11 endmodule

o head
display the 1st 10 lines from top of the file in to the terminal

head filename.extension

example:-
Q. display 1st 5 line of the file.
Ans:-
head -5 filename.extension

o tail
display the last/bottom 10 lines from of the file in to the terminal
tail filename.extension

example:-
Q. display last 5 line of the file.
Ans:-
tail -5 filename.extension

o more
display the file content screen by scrren on to the terminal

more filename.txt

o less
we flexibility of scrolling (similar to more command)
7. mv
move file or move directory(simar to cut and paste operation in windows)

mv <dir_path>/source <dir_path>/destination
source can be file_name or dir_name
destination can be dir_name

example:-
Q. create two directory called as demo1 and demo2
create two to three random file in both the directory(i.e demo1
and demo2)
-> in demo1
create files such as add.txt sub.txt mul.txt
write some random content into them
-> in demo2
create files such as agent.sv env.sv
write some random content into them

task1:- move agent.sv file from demo2 to demo1


$ mv demo2/agent.sv demo1/

task2:- move all the text file from demo1 to demo2


$ mv demo1/*.txt demo2/

task3:- move entire demo2 directory into demo1 directory


$ mv demo2 demo1

Q.
mv /path/demo1/add.txt demo1/sub.txt demo1/mul.txt path/demo2

now if my demo1 directory had 20 txt files then wt to do?


mv /path/demo1/*.txt /path/demo2

12. history
13. ping
16. vi
17. rm
18. rmdir
19. wc
20. nl -> not important
21. chmod
22. uniq -> not important
23. grep
-c
-w
-i
-r
-o
-l
-h
-n
-v
-e
24. ls
-l
-a
-r
-h
-t
25. meta char
*
?

You might also like