Unix Commands

  • Uploaded by: api-26041653
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Unix Commands as PDF for free.

More details

  • Words: 1,498
  • Pages: 29
UNIX COMMANDS

Simple UNIX Commands File Related Commands Directory related Commands

Simple UNIX Commands logname who who am i date cal uname bc expr tty factor

prints the login name of the user details of the all the user currently logged in identifies the user tells the current date and time displays current month calendar finds the name of UNIX system best calculator is invoked. To exit type ‘quit’ allows expressions to be evaluated in command prompt prints the name of the terminal finds the factors of a number

Simple UNIX Commands $ logname cs2k4b01

$ who cs2k4b01 tty1 cs2k4b01 tty2

Jan 16 10:02 Jan 16 10:05

$ who am i cs2k4b01 tty1

Jan 16 10:02

Simple UNIX Commands $ date Mon Jan 2 10:15:09 IST 2007

$ uname Linux

$ expr 3 \* 2 6

Simple UNIX Commands $ tty $ factor

/dev/tty1 15 15: 3 5 28 28: 2 2 7

$ banner Operating Systems Lab Operating Systems Lab

$ banner “Operating Systems Lab” Operating

Simple UNIX Commands $ cal

$ cal 4 2004

January 2006 Su Mo Tu We Th Fr Sa 1234567 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

April 2004 Su Mo Tu We Th Fr Sa 123 4 5 6 7 8 9 10 11 12 13 1415 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Simple UNIX Commands $ bc bc 1.06 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type ‘warranty’. 2+2 4 sqrt(196) 14 s(3.14) Runtime error (func=(main), adr=8): Function s not defined. quit

Simple UNIX Commands $ bc -l bc 1.06 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type ‘warranty’. scale = 2 s(3.14) 0 quit

File Related Commands cat ls head tail cp rm file * touch wc

creates a file lists current directory displays first ten lines of the file displays last ten lines of the file copies the contents of the file removes file prints the type of each file in the current directory creates multiple files counts the number of words, lines and characters

chmod sort

allows to modify permission sorts the datas

uniq ln

eliminates duplicate values link created

File Related Commands $ touch f1 $ touch f2 f3 f4 f5 $ cat >f6 this is file 6 $ cat f6 this is file 6

$ cat >f7 this is file 7

File Related Commands $ cat f6 f7>f8 $ cat f8

this is file 6 this is file 7

$ cat > f9 this is file 9 $ cat f6 f7>>f9 this is file 9 this is file 6 this is file 7

File Related Commands $ head -2 f9 $ tail -2 f9 vi file1.a

this is file 9 this is file 6 this is file 6 this is file 7 this is file1.a

cp file1.a file2.a cat file2.a this is file1.a

cat>f10 this is file 10

File Related Commands $ cat >.f11 this is file 11 $ ls $ ls f1?

f1 …….. file1.a file2.a

f10

f10

$ ls -a f1

……..

f10

f1

$ ls f1*

f11

File Related Commands $ rm f9 $ ls

f1

……..

f8

chmod [who] [+/-/=] [permission] filename $ chmod 777 f8 $ chmod 444 f8 (OR) $ chmod ugo-wx f8 $ rm f8 rm: remove write-protected regular file ‘f8’? n $ rm f8 -f $ ls

f1

……..

f7

File Related Commands $ rm f7 -i rm: remove regular file ‘f7’? y $ ls

f1

……..

f6

$ mv f2 f3 $ cat f3 this is file 2

$ ls f1

f3

……..

f7

File Related Commands $ file *

$ wc –lc f1

f1: . .

ASCII text

1

15

f1

f1

f3

……..

$ cat >>f3 $ ls f7

File Related Commands $ ls -l -s -i

ln f1 f15 ls -l

$ cat > s1 def abc

long listing display with file sizes displays with the inode number

total 22 -rwxrwxr-- 2 cs2k5a01 cs2k5a 4 2 Jan 07 10:15 f1 -rw-rw-r-- 1 cs2k5a01 cs2k5a 5 2 Jan 07 10:16 f5 -rwxrwxr-- 2 cs2k5a01 cs2k5a 4 2 Jan 07 10:15 f15

File Related Commands $ sort s1 $ sort s1 s3 $ sort –r -u -o filename -f -n -m -

abc def

reverse order unique output sorted output to a file ignoring case sort numbers merge keyboard input with a file

File Related Commands $ cat > s2 4 abc 50 3 ghi 60 2 def 70 1 wef 80 $ cut –f 2,4 s2

$ cut –f 2-4 s2

51 61 71 81

52 62 72 82 abc ghi def wef

51 61 71 81

abc ghi def wef

50 60 70 80

51 61 71 81

File Related Commands $ cat > s2 4:abc:50:51:52 3:ghi:60:61:62 2:def:70:71:72 1:wef:80:81:82 $ cut –f 2,4 –d”:” s2 $ cut –c 2-4 –d”:” s2 $ sort –r +1 -2 s2

abc ghi def wef abc ghi def wef wef ghi def abc

51 61 71 81

File Related Commands $ grep a* s2

1

abc

16

$ grep [D-G]?f -i -n s2 3:2

$ grep ‘^[def]’ s2

def

24

$ grep ‘[def]$’ s2

$ uniq f3 -d -u -c

remove duplicate data display unique data count number of times the word is present in the file

Directory Related Commands pwd mkdir cd cd .. rm mv

prints present working directory creates a directory changing over to new directory brings you back to home directory removes all contents of directory renames the directory name

ls

long listing of directory

Directory Related Commands $ pwd /home/cs2k4b/cs2k4b01

$ mkdir d1 $ cd d1 $ cd .. $ mv d1 d2

COMMANDS TO EXECUTED 1. Command to print the login name of the use 2. To display the Users 3. To display the present user alone 4. Print the current date 5. Print the present working directory 6. Print the calendar 7. Print the calendar for October 2003 8. Print the name of the UNIX system 9. Create a file 10. Print the terminal name 11. Create multiple files 12. List all the files and directories in the current directory

COMMANDS TO EXECUTED 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24.

13. To create a file fn in write mode To display the contents of the file fn Copy the contents of two files into a third file Append the contents of two file into a third file Display the first n lines of a filename fn Display the last n lines of a filename fn Create a file in vi editor mode Copy the contents of one file into another Create a directory Copy files into the directory To change directory To move to the parent directory

COMMANDS TO EXECUTED ∗ 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36.

25. Copy a file from one directory to another Remove a file Remove with confirmation Remove without confirmation (forcibly) Move contents from one file to another file To create a hidden file To view the hidden file To view all the files starting with the given letter To view all the files starting with either of the given letters (aeiou) To view all the files starting with the letters other than (aeiou) Long listing To list file types

COMMANDS TO EXECUTED ∗ 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48.

37. To list the files with sizes in the particular directory Give all rights for the user, for group give only write and execute permission Give only execute permission for others (both methods) To list file with inode number Calculator Calculator with trignometric library Evaluating expression Factor of a number Word count (lines, words & characters) Sort a file fn Sort a file in reverse Display unique output of a file

COMMANDS TO EXECUTED ∗ 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60.

49. To append contents to a file Sort ignoring case Sort numbers Sort the contents of two files and store it in another file Sort and merge two files Sort the standard input Sort the standard input with the file content Rename a directory Move files in a directory Display the selected fields in the file Search for the given pattern and print it Search for the pattern ignoring case and starting with either of [a-f] in the file and print it

COMMANDS TO EXECUTED ∗

61. Search for the pattern ending with either of [s-z] in the file and print it along with the line numbers 62. Ignore duplicate data and print it 63. Print the unique data 64. Count the number of times the particular data is present in the file 65. Create link between the two files (long list after link creation)

Related Documents

Unix Commands
April 2020 10
Unix Commands
July 2020 7
Unix Commands
November 2019 20
Unix Commands
April 2020 8
Unix Commands
June 2020 4
Unix Commands
May 2020 6