You are on page 1of 16

U.V.

Patel College of Engineering


B. Tech Computer Science and Engineering
Sub: Basics of Operating System and Shell Scripting
(2CSE204)

NAME : DHRUV PANDIT

CLASS : CBA

ENROLMENT NO : 16012101007

BATCH : CSE - 21

PRACTICAL 3:
PROCESS RELATED LINUX COMMANDS

1)ps - report a snapshot of the current processes.

ps displays information about a selection of the active processes. If

you want a repetitive update of the selection and the displayed

information, use top(1) instead.

2) kill - send a signal to a process

The default signal for kill is TERM. Use -l or -L to list available

signals. Particularly useful signals include HUP, INT, KILL, STOP,

CONT, and 0. Alternate signals may be specified in three ways: -9,

-SIGKILL or -KILL. Negative PID values may be used to choose whole

process groups; see the PGID column in ps command output. A PID of -1

is special; it indicates all processes except the kill process itself

and init.

Syntax:
ps [options]

Syntax:
kill [options] <pid> [...]

-l, --list [signal]


List signal names. This option has optional argument, which

will convert signal number to signal name, or other way round.

-L, --table

List signal names in a nice table.

3)cmp - compare two files byte by byte

Compare two files byte by byte.

The optional SKIP1 and SKIP2 specify the number of bytes to skip at the

beginning of each file (zero by default).

Syntax:
cmp [OPTION]... FILE1 [FILE2 [SKIP1 [SKIP2]]]

-b, --print-bytes

print differing bytes

-i, --ignore-initial=SKIP

skip first SKIP bytes of both inputs

4)rm - remove files or directories

This manual page documents the GNU version of rm. rm removes each

specified file. By default, it does not remove directories.

If the -I or --interactive=once option is given, and there are more

than three files or the -r, -R, or --recursive are given, then rm

prompts the user for whether to proceed with the entire operation. If
the response is not affirmative, the entire command is aborted.

Otherwise, if a file is unwritable, standard input is a terminal, and

the -f or --force option is not given, or the -i or --interac

tive=always option is given, rm prompts the user for whether to remove

the file. If the response is not affirmative, the file is skipped.

Syntax:
rm [OPTION]... FILE...

-f, --force

ignore nonexistent files and arguments, never prompt

-i prompt before every removal

USER RELATED LINUX COMMANDS

1)uname - print system information

Print certain system information. With no OPTION, same as -s.

Syntax:
uname [OPTION]...

-a, --all

print all information, in the following order, except omit -p

and -i if unknown:

-s, --kernel-name

print the kernel name

2) passwd - change user password


The passwd command changes passwords for user accounts. A normal user

may only change the password for his/her own account, while the

superuser may change the password for any account. passwd also changes

the account or associated password validity period.

Syntax:
passwd [options] [LOGIN]

3) useradd - create a new user or update default new user information

useradd is a low level utility for adding users. On Debian,

administrators should usually use adduser(8) instead.

When invoked without the -D option, the useradd command creates a new

user account using the values specified on the command line plus the

default values from the system. Depending on command line options, the

useradd command will update system files and may also create the new

user's home directory and copy initial files.

Syntax:
useradd [options] LOGIN

useradd -D

useradd -D [options]

4) groupadd - create a new group


The groupadd command creates a new group account using the values

specified on the command line plus the default values from the system.

The new group will be entered into the system files as needed.

Syntax:

groupadd [options] group

-h, --help

Display help message and exit.

-K, --key KEY=VALUE

Overrides /etc/login.defs defaults (GID_MIN, GID_MAX and others).

Multiple -K options can be specified.

5)groupdel - delete a group

The groupdel command modifies the system account files, deleting all

entries that refer to GROUP. The named group must exist.

Syntax:
groupdel [options] GROUP

-h, --help

Display help message and exit.

-R, --root CHROOT_DIR

Apply changes in the CHROOT_DIR directory and use the configuration

files from the CHROOT_DIR directory.

6)su - change user ID or become superuser

The su command is used to become another user during a login session.


Invoked without a username, su defaults to becoming the superuser. The

optional argument - may be used to provide an environment similar to

what the user would expect had the user logged in directly.

Syntax:
su [options] [username]

-c, --command COMMAND

Specify a command that will be invoked by the shell using its -c.

The executed command will have no controlling terminal. This option

cannot be used to execute interractive programs which need a

controlling TTY.

-, -l, --login

Provide an environment similar to what the user would expect had

the user logged in directly.

When - is used, it must be specified as the last su option. The

other forms (-l and --login) do not have this restriction.

7)sudo, sudoedit execute a command as another user

sudo allows a permitted user to execute a command as the superuser or

another user, as specified by the security policy.

Syntax:
sudo -h | -K | -k | -V

sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]

sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]

[command]
sudo [-AbEHnPS] [-C num] [-g group] [-h host] [-p prompt] [-r role]

[-t type] [-u user] [VAR=value] [-i | -s] [command]

sudoedit [-AknS] [-C num] [-g group] [-h host] [-p prompt] [-u user] file

-h, --help Display a short help message to the standard output and exit.

-b, --background

Run the given command in the background. Note that it is not

possible to use shell job control to manipulate background

processes started by sudo. Most interactive commands will

fail to work properly in background mode.

8)who - show who is logged on

Print information about users who are currently logged in.

Syntax:
who [OPTION]... [ FILE | ARG1 ARG2 ]

-a, --all

same as -b -d --login -p -r -t -T -u

-b, --boot

time of last system boot

9) whoami - print effective userid

Print the user name associated with the current effective user ID.

Same as id -un.

--help display this help and exit


--version

output version information and exit

Syntax:

whoami [OPTION]...

10) login, logout - write utmp and wtmp entries

The utmp file records who is currently using the system. The wtmp file

records all logins and logouts. See utmp(5).

The function login() takes the supplied struct utmp, ut, and writes it

to both the utmp and the wtmp file.

The function logout() clears the entry in the utmp file again.

Syntax:
#include <utmp.h>

void login(const struct utmp *ut);

int logout(const char *ut_line);

11) exit - cause normal process termination

The exit() function causes normal process termination and the value of

status & 0377 is returned to the parent (see wait(2)).

Syntax:

#include <stdlib.h>
void exit(int status);

FILE SYSTEM LINUX COMMANDS

1) find - search for files in a directory hierarchy

This manual page documents the GNU version of find. GNU find searches

the directory tree rooted at each given file name by evaluating the

given expression from left to right, according to the rules of prece


dence (see section OPERATORS), until the outcome is known (the left

hand side is false for and operations, true for or), at which point

find moves on to the next file name.

Syntax:
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression]

The -H, -L and -P options control the treatment of symbolic links.

2)mount - mount a filesystem

All files accessible in a Unix system are arranged in one big tree, the

file hierarchy, rooted at /. These files can be spread out over sev

eral devices. The mount command serves to attach the filesystem found

on some device to the big file tree. Conversely, the umount(8) command

will detach it again.

Syntax:

mount [-lhV]

mount -a [-fFnrsvw] [-t vfstype] [-O optlist]

mount [-fnrsvw] [-o option[,option]...] device|dir

mount [-fnrsvw] [-t vfstype] [-o options] device dir

mount -h

prints a help message

mount -V
prints a version string

3) df - report file system disk space usage

This manual page documents the GNU version of df. df displays the

amount of disk space available on the file system containing each file

name argument. If no file name is given, the space available on all

currently mounted file systems is shown. Disk space is shown in 1K

blocks by default, unless the environment variable POSIXLY_CORRECT is

set, in which case 512-byte blocks are used.

Syntax:

df [OPTION]... [FILE]...

-a, --all

include dummy file systems

-B, --block-size=SIZE

scale sizes by SIZE before printing them. E.g., '-BM' prints

sizes in units of 1,048,576 bytes. See SIZE format below.

4) fdisk - manipulate disk partition table

fdisk (in the first form of invocation) is a menu-driven program for

creation and manipulation of partition tables. It understands DOS-type

partition tables and BSD- or SUN-type disklabels.

fdisk does not understand GUID partition tables (GPTs) and it is not

designed for large partitions. In these cases, use the more advanced
GNU parted(8).

fdisk does not use DOS-compatible mode and cylinders as display units

by default. The old deprecated DOS behavior can be enabled with the

'-c=dos -u=cylinders' command-line options.

Syntax:
fdisk [-uc] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device

fdisk -l [-u] [device...]

fdisk -s partition...

fdisk -v

fdisk -h

5) free - Display amount of free and used memory in the system

free displays the total amount of free and used physical and swap mem

ory in the system, as well as the buffers used by the kernel. The

shared memory column represents either the MemShared value (2.4 series

kernels) or the Shmem value (2.6 series kernels and later) taken from

the /proc/meminfo file. The value is zero if none of the entries is

exported by the kernel.

Syntax:
free [options]
-b, --bytes

Display the amount of memory in bytes.

-k, --kilo

Display the amount of memory in kilobytes. This is the default.

6) top - display Linux processes


The top program provides a dynamic real-time view of a running

system. It can display system summary information as well as a

list of processes or threads currently being managed by the Linux

kernel. The types of system summary information shown and the

types, order and size of information displayed for processes are

all user configurable and that configuration can be made persis

tent across restarts.

Syntax:
top -hv|-bcHiOSs -d secs -n max -u|U user -p pid -o fld -w [cols]
OTHER COMMANDS

1) echo - display a line of text

Echo the STRING(s) to standard output.

Syntax:
echo [SHORT-OPTION]... [STRING]...

echo LONG-OPTION

-n do not output the trailing newline

-e enable interpretation of backslash escapes


2) cal, ncal displays a calendar and the date of Easter

The cal utility displays a simple calendar in traditional format and ncal

offers an alternative layout, more options and the date of Easter. The

new format is a little cramped but it makes a year fit on a 25x80 termi

nal. If arguments are not specified, the current month is displayed.

Syntax:
cal [-3hjy] [-A number] [-B number] [[month] year]

cal [-3hj] [-A number] [-B number] -m month [year]

ncal [-3bhjJpwySM] [-A number] [-B number] [-s country_code] [[month]

year]

ncal [-3bhJeoSM] [-A number] [-B number] [year]

ncal [-CN] [-H yyyy-mm-dd] [-d yyyy-mm]

-h Turns off highlighting of today.

-J Display Julian Calendar, if combined with the -o option, display

date of Orthodox Easter according to the Julian Calendar.

3) expr - evaluate expressions

--help display this help and exit

--version

output version information and exit

Syntax:
expr EXPRESSION

expr OPTION

You might also like