0% found this document useful (0 votes)
11 views8 pages

OS Exp1 S21 72

The document outlines various basic Linux commands and system calls related to file, directory, and process management. Each command is described with its name, syntax, and theory, covering commands like mkdir, chdir, cat, ls, and system calls such as open, read, and write. It serves as a practical guide for understanding and using these commands in a Linux environment.

Uploaded by

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

OS Exp1 S21 72

The document outlines various basic Linux commands and system calls related to file, directory, and process management. Each command is described with its name, syntax, and theory, covering commands like mkdir, chdir, cat, ls, and system calls such as open, read, and write. It serves as a practical guide for understanding and using these commands in a Linux environment.

Uploaded by

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

Name – Kunal Motwani

Div-S2
Batch-S21
Branch-AI&DS
Roll no-72

EXPERIMENT NO 1
AIM: Explore usage of basic Linux Commands and system calls forfile, directory and
process management.

1. mkdir:
Command Name: Make Directory
Syntax: mkdir OPTIONS <DIRECTORY>
Theory: The mkdir command in Linux/Unix allows users to create or make new directories. mkdir stands for “make
directory.” With mkdir , you can also set permissions, create multiple directories (folders) at once, and much more

Output:

2. chdir:
Command Name: Change Directory
Syntax: chdir OPTIONS <DIRECTORY>
Theory: The chdir command is a system function(system call) which is used to change the current working directory. On
some systems, this command is used as an alias for the shell command cd. chdir changes the current working directory
of the calling process to the directory specified in path.
Output:
3. cat:
Command Name: Concatenate
Syntax: cat[benstuv][file...]
Theory: The cat (short for “concatenate“) command is one of the most
frequently used commands in Linux/Unix like operating systems. cat
command allows us to create single or multiple files, view contain of file,
concatenate files and redirect output in terminal or files

Output:

4. ls:
Command Name: List
Syntax: ls[flags][directory]
Theory: ls is a Linux shell command that lists directory contents of files and
directories. Ls with no option list files and directories in bare format where we won’t
be able to view details like file types, size, modified date and time, permission and
links etc.

Output:
5. chown:
Command Name: Change owner
Syntax: chown OPTIONS USER[:GROUP]file_name
Theory: the command can be used with or without additional options. [USER] – the
username or the numeric user ID of the new owner of a file. [:] – use the colon when
changing a group of a file. [GROUP]–changing the group ownership of a file is optional.

6. chmod:
Command Name: change mode
Syntax: chmod REFERENCE OPERATOR MODE file_name
Theory: In Linux, who can do what to a file or directory is controlled through sets of
permissions. There are three sets of permissions. One set for the owner of the file, another set
for the members of the file’s group and a final set for everyone else.

7. chgrp:
Command Name: Change Group
Syntax: chgrp OPTIONfile_name
Theory: chgrp command in Linux is used to change the group ownership of a file or directory.
All files in Linux belong to a now neranda group. You canse the owner by using the “chown”
command, and the group by the “chgrp” command.

8. ps:
Command Name: Process status
Syntax: ps [-AaceHhjkLlmrSTuvwx] [-M core] [-N system] [-O
fmt] [-o fmt] [-ppid] [-t tty] [-U username] [-W swap]
Theory: ps command is used to list the currently running processes and their PIDs along with
some other information depends on different options. It reads the process information from
the virtual files in /proc file system.
Output:
System calls:
1. open:
Command Name:OpenFile
Syntax:open(constchar*pathname,intflags,mode_tmode);
Theory: Used to Open the file for reading, writing or both.

2. read:
Command Name:ReadFile
Syntax:read(intfd,void*buf,size_tcount);
Theory: From the file indicated by the file descriptor fd, the read() function reads cnt bytes
Of input into the memory area indicated by buf. A successful read() updates the access time
for the file.

3. write:
Command Name:Writetoafiledescriptor
Syntax:write(intfd,constvoid*buf,size_tcount);
Theory:Write scnt bytes from buf to the file or socket associated with fd. Cnt
should not be greater than INT_MAX (defined in the limits.h header file). If cnt is
zero, write() simply returns 0 without attempting any other action.

4. close:
Command Name:Closeafiledescriptor
Syntax:close(intfd);
Theory: Tell the operating system you are done with a file descriptor and Close the file
which is pointed by fd.

5. getpid:
Command Name:Getprocessidentification
Syntax:getpid(void);
Theory:returns the process do the calling process. This is often used by routines
that generate unique temporary filenames.

6. setpgid:
Command Name:Setprocessgroup
Syntax:setpgid(pid_tpid,pid_tpgid);
Theory: setpgid() sets the process group ID of the process specifiedcby pid to pgid. If pid
is zero, the process ID of the current process is used. If pgidis zero, the process ID of the
process specified by pid is used.

7. getuid:
Command Name:Getuseridentity
Syntax:getuid(void);
Theory:The getuid() function returns the real user ID of the calling process. There user ID
identifies the person who is logged in.

8. getgid:
Command Name:Getgroupidentity
Syntax:getgid(void);
Theory:Returns the real group ID of the calling process.

9. getegid:
Command Name:Getgroupidentity
Syntax:getegid(void);
Theory:Returns the effective group ID of the calling
process.

10. geteuid:
Command Name:Getuseridentity
Syntax:geteuid(void);
Theory: The geteuid() function returns the effective user ID of the calling process. The
effective user ID gives the process various permissions during execution of “set-user-ID”
mode processes which use getuid()to determine the real user ID of the process that invoked
them.

11. sort:
Command Name:sort
Syntax:sort[OPTION]...[FILE]...
Theory:It is used to sort the contents of the file.

12. grep:
Command Name: Globally search for a Regular Expression
and Print matching lines Syntax: grep [OPTIONS]
PATTERN [FILE...]
Theory:The grep filter searches a file for a particular pattern of characters, and displays
all lines that contain that pattern. The pattern that is searched in the file is referred to as
the regular expression (grep stands for globally search for regular expression and print
out).

13. awk:
Command Name:Aho,Weinberger,Kernighan
Syntax:awkoptions'selection_criteria{action}'input-file
> output-file Theory: Awk is a scripting language used for manipulating data and
generating reports. The awk command programming language requires no compiling, and
allows the user to use variables, numeric functions, string functions, and logical operators.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy