0% found this document useful (0 votes)
2 views6 pages

C Lab

The document provides an overview of Linux/Ubuntu commands essential for operating within this multi-user and multi-tasking operating system. It outlines the purpose of commands, their syntax, and examples for file and directory management, system information, and permissions. The document emphasizes the case sensitivity of commands and the importance of using the terminal for executing these instructions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

C Lab

The document provides an overview of Linux/Ubuntu commands essential for operating within this multi-user and multi-tasking operating system. It outlines the purpose of commands, their syntax, and examples for file and directory management, system information, and permissions. The document emphasizes the case sensitivity of commands and the importance of using the terminal for executing these instructions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

An overview of certain Linux/Ubuntu Commands

BACHELOR OF TECHNOLOGY (B.TECH)


PROGRAMMING in C
LINUX/UBUNTU – A multi-user and multi-tasking operating system.

An operating system is the most important program that runs on a computer.


Every general-purpose computer must have an operating system to run other
programs and applications. Operating system perform some basic tasks, such as
recognizing input from the keyboard, sending output to the display screen,
keeping track of files and directories on the disk, and controlling peripheral
devices such as disk drives and printers.

Linux kernel can offer the following features:


Ubuntu is a multi-user operation system. Only authorized user can use/work on a
Linux system. In order to work on such a system one must a User ID and a
Password.

Most of the fundamental activities under this platform are being performed in an
interactive mode. In other words those actions can be executed by typing certain
COMMAND.

What is a Command in Ubuntu/Linux?

A command is an instruction you type into the terminal (also called the command-
line interface) that tells the operating system to do something.

Ubuntu/Linux comes with a lot of commands each one having a definite purpose.

The basic need of this Lab Session is to provide you certain operational exposure
over this platform. In turn we will make you understand some of such
Linux/Ubuntu command, so that you will be comfortably work on this
environment and conveniently implement various programming concepts latter
on.
Please note the Linux/Ubuntu is a case sensitive Operating System that implies
Following are a list of frequently used Ubuntu/Linux commands you need to note
down as well as practice.

File and Directory Management:


 date : Prints the current/system data
 cal : Prints the Calendar
 ncal : Prints the Calendar
 pwd: Prints the current working directory.
 ls: Lists the contents of a directory.

Syntax : ls [option] [path]

Options:
-l – long listing
-d – directory
-a – for hidden files
Example :
ls
ls -l
ls -d
ls -a

 mkdir: Creates a new directory.

Syntax : mkdir [path] Folder/Directory name

Example:
mkdir NIST

 cd: Changes the current directory.

Syntax : cd [path] Folder/Directory name

Example:
cd NIST

 rmdir: Removes an empty directory.

Syntax : cd [path] Folder/Directory name

Example:
cd NIST

 cp: Copies files or directories.

Syntax : cp Sourcefile Targetfile

cd .. go to parent directory

Example:
cp myfile.txt myfile1.txt
Copies the contents myfile.txt into myfile1.txt and both files exists
 mv: Moves or renames files or directories.
Syntax : mv Oldfile Newfile

Example:
mv myfile.txt mynewfile.txt
Renames myfile.txt into mynewfile.txt

 rm: Removes files or directories. Use rm -r for directories.

Syntax: rm Filename

Options:
-i - interactively
-f - forcefully
Example:
rm myfile1.txt

 cat: Displays the contents of a file. Also used to create a new file.

Syntax: cat file1 file2 file3 ……

Example:
cat mynewfile.txt

To create a new file: cat > filename


Type lines of the text.
Finally press : Ctrl+d to save the file
 wc : Counts the lines, words and characters in a file.
Syntax: wc [option] filename
Options:
-l - counts only lines
-w - counts only words
-c - counts only characters

Example:
wc myfile.txt
wc -l myfile.txt
wc -w myfile,txt
wc -c myfile.txt

 head: Displays the beginning of a file. By default this command displays 10


lines from the beginning.

Syntax: head [option] filename


Example:
head myfile.txt
head -n 12 myfile.txt
head -n 5 myfile.txt
 tail: Displays the end of a file. By default this command displays 10 lines
from the end.

Syntax: tail [option] filename


Example:
tail myfile.txt
tail -n 12 myfile.txt
tail -n 5 myfile.txt

System Information and Utilities:

 whoami: Displays the current username.


 clear: Clears the terminal screen.

 man: Displays the manual page for any given command.

Syntax : man command


Example :
man ls
man mkdir
man head

 grep: Searches for patterns in files.

Global regular expression print or grep lets you search specific words from
a file.
Syntax: grep [options] keyword [file]
Example: grep “nist” file.txt
It will the word “nist” inside a file named file.txt

 sort: Sorts the contents of a files.

Syntax: sort filename

Example: sort myfile.txt

 ps: Displays information about running processes(just type the command


on terminal.

 kill: Sends a signal to terminate a process.


Syntax : kill [option] ProcessID

Permissions and Ownership:


 chmod: Changes file permissions.
 chown: Changes file ownership.
 chgrp: Changes file group ownership.

In order to check above commands you need to open the Terminal Tool. Over the
Terminal each command is required to type with proper syntax should be small
letters only.

You might also like