Linux commands can be used from the terminal to navigate directories, view and manipulate files. Some key commands include ls to list files, cd to change directories, cat to view file contents, mkdir to create directories, and rm to delete files. Top provides a dynamic view of running processes and their resource usage, while kill terminates running processes.
The document provides summaries of various Linux commands:
- The man command displays the manual for a command, including its name, synopsis, description, options, exit status, errors, versions, examples, and more.
- The pwd command prints the path of the current working directory.
- The cal command displays the calendar for the current or specified month and year.
The document provides an overview of common Linux commands, including:
- cd to change directories
- ls to list directory contents
- mkdir to create directories
- pwd to print the working directory
- rm to remove files
- rmdir to remove directories
- cp to copy files
- find to locate files
- more and less to view file contents
- vi as a basic text editor
- ps to view running processes
- kill to terminate processes
This document provides a cheat sheet of common Linux/Unix commands and their descriptions. It includes commands for navigating directories, manipulating files and directories, viewing file contents, searching files, running processes, and getting help. Wildcards and relative paths are also explained. The summary highlights commands for changing directories (cd), listing contents (ls), creating/removing files and directories (touch, mkdir, rm), viewing file contents (cat, more, head, tail), and getting help (man).
The document provides an overview of basic command line commands for Mac, Linux, and Windows operating systems. It discusses how to set up the command line interface, introduces common commands like cd, ls, pwd, and touch. It also covers manipulating files through commands like mkdir, rm, cp, and mv. The document aims to teach fundamental navigation, file management and copying skills through hands-on practice of basic commands in the terminal.
This document contains an assignment submission for a 4th semester networking course at the University of Engineering and Technology in Taxila, Pakistan. The assignment was submitted by M. Ubaid Ashraf with registration number 20-CP-09 to professor Sir Adnan Mustafa. The assignment contains 18 tasks related to Linux commands like cd, ls, touch, cat etc. and includes writing a simple shell script to calculate interest and explaining the purpose of commands like kill, grep, tail etc.
Lab 3 -Linux Files, Directories and Basic Commands.pptxCiceer Ghimirey
油
This document provides an overview of basic Linux commands for files, directories, and permissions. It describes the following commands: cd, ls, cp, rm, mkdir, rmdir, pwd, file, cat, more, less, chmod, and chown. For each command, it provides the syntax and brief description of its usage for listing, copying, deleting, creating, and navigating files and directories, determining file types, viewing file contents, and changing permissions and ownership of files.
Lab 3 -Linux Files, Directories and Basic Commands.pptxCiceer Ghimirey
油
This document provides an overview of basic Linux commands for files, directories, and permissions. It describes the following commands: cd, ls, cp, rm, mkdir, rmdir, pwd, file, cat, more, less, chmod, and chown. For each command, it provides the syntax and brief description of its usage for listing, copying, deleting, creating, and navigating files and directories, determining file types, viewing file contents, and changing permissions and ownership of files.
This document provides an overview of basic Linux commands, including man for accessing manual pages, ls for listing directory contents, mkdir for creating directories, cd for changing directories, pwd for printing the working directory, and ~ for accessing the home directory. It also covers commands for copying, moving, removing files, clearing the screen, viewing file contents, searching within files, counting words, piping commands together, using wildcards, and changing file permissions with chmod. The document encourages learning through manual pages and understanding error messages.
This document provides an overview of basic Linux commands for common file system tasks like navigating directories, managing files, and copying or moving files. It describes commands like pwd to print the working directory, cd to change directories, ls to list directory contents, mkdir to create directories, cat to view file contents, rmdir to delete empty directories, rm to delete files and directories, and cp and mv to copy and move files between locations.
The document provides 40 tips for using basic Linux command line commands and tricks. Some key points include: everything in Linux is a file; # and $ denote superuser and normal users respectively; Ctrl+Alt+F1-F6 switch between terminals while Ctrl+Alt+F7 switches to the GUI; tilde ~ denotes the user's home directory; hidden files start with a dot; ls -a views hidden files; file permissions use rwx notation; and variables can be assigned text for repeated use.
The document provides 40 tips for using basic Linux command line commands and tricks. Some key points include: everything in Linux is a file; # and $ denote superuser and normal users respectively; Ctrl+Alt+F1-F6 switch between terminals while Ctrl+Alt+F7 switches to the GUI; tilde ~ denotes the user's home directory; hidden files start with dot; ls -a views hidden files; file permissions use rwx scheme; and variables can store long text for repeated use.
This document provides summaries of common Linux commands, including ls, mkdir, cd, rmdir, rm, cp, mv, touch, echo, head, tail, less, more, grep, find, man, wc, pipe (|), cat, and mv. It describes the basic syntax and common examples for using each command to list, create, delete, copy, move, view, and filter files and directories from the command line.
The document provides descriptions of various Linux commands for basic usage and pentesting. It describes commands for making directories (mkdir), deleting empty directories (rmdir), viewing processes (ps), checking username (whoami), checking disk space (df), displaying date and time (date), checking connectivity (ping), downloading files (wget), looking up domain registration records (whois), navigating directories (cd), listing directory contents (ls), displaying command manuals (man), displaying text files (cat), copying files (cp), moving and renaming files (mv), removing files and directories (rm), creating empty files (touch), searching files (grep), using administrative privileges (sudo), viewing start of files (head), viewing end of files (
1. The document provides examples of common Linux commands and their usage including tar, grep, find, ssh, sed, awk, vim, diff, sort, export, xargs, ls, ifconfig, uname, ps, free, top, df, kill, rm, cp, mv, cat, mount, chmod, chown, passwd, mkdir, ifconfig, uname, whereis, whatis, and locate.
2. Examples shown include how to create, extract, and view tar archives, search files with grep, find files, login remotely with ssh, edit files with vim, compare files with diff, view processes with ps, check storage usage with df, terminate processes with kill, manage files
The document provides an overview of essential Linux commands and concepts, organized into sections on essential commands, command structure, help, moving around directories, reading and writing files, directories, moving and renaming files, copying and removing files, links, searching, ownership and permissions, switching users, and useful commands. Key commands covered include ls, cd, pwd, touch, mkdir, mv, cp, rm, chmod, and sudo. File permissions are explained using rwx notation and octal representation.
Linux is an open-source operating system based on Unix, designed for multi-user environments. The document provides an overview of basic Linux commands like ls, mkdir, cd for navigating files and directories, as well as more advanced commands for manipulating files, checking system resources, and getting system information. It also lists and describes many common Linux commands and their functions.
The document discusses Linux commands for file management and viewing. It describes commands for navigating directories (cd), changing file permissions (chmod), copying files (cp), finding files (find), listing directory contents (ls), creating and removing directories (mkdir, rmdir), moving and renaming files (mv), viewing file contents (cat, head, tail), comparing files (cmp, diff), searching files (grep), and more. It also covers commands for compressing, archiving, and backing up files like tar, gzip, zip, and commands for counting, sorting, and filtering file contents.
This document provides an overview of common UNIX commands for navigating directories, listing files, editing text, searching for files and strings, compressing files, and more. It describes commands like ls, cd, pwd, vi, grep, find, tar, gzip and man for viewing manual pages. It also explains concepts like pipes, redirection, environment variables and basics of the awk command for text manipulation.
Linux is an open source operating system initially created by Linus Torvalds in 1991. It has since grown significantly with hundreds of companies and individuals developing their own versions based on the Linux kernel. The kernel is developed under the GNU GPL license and its source code is freely available. Basic Linux commands allow users to navigate directories, manage files and permissions, transfer files, and get system information. More advanced commands provide additional control and functionality.
The document provides an overview of common Linux commands, including commands for executing other commands, navigating directories, listing and copying files, managing users and permissions, searching for files, processing text, managing archives, and compressing files. Examples are given for commands like ls, cd, cp, mv, rm, who, echo, alias, awk, chown, diff, grep, pushd, kill, df, cat, tar, gzip, su. Brief descriptions are provided for most commands and references are given at the end for additional Linux resources.
This document provides an introduction to Linux, including:
- What Linux is and where it came from, as an open source operating system created by Linus Torvalds in 1991.
- How to get Linux through downloading a distribution like Red Hat and the packages it includes.
- Why Linux has become significant due to its growing popularity, ability to run on multiple hardware platforms, and being free.
- An overview of Linux commands and utilities for file management, processes, users and permissions.
This document provides an overview of basic Unix commands including ls, cd, pwd, mkdir, rm, rmdir, cp, find, touch, echo, cat, who, and du. It explains what each command is used for and provides examples of common usages. The document serves as a beginner's guide to learning Unix commands.
The document provides an overview of 11 common UNIX commands used in the Mac terminal: ls, cd, pwd, mkdir, rm, mv/cp, who, cat, sudo, control+C, and clear. It describes what each command does and provides examples of basic usage. The document explains that while the Mac OS is based on UNIX, Windows uses different DOS commands that are not compatible. It encourages users to get familiar with UNIX commands to expand their coding skills.
The document provides an overview of common Unix commands for navigating directories, managing files, and examining file contents. It discusses commands for changing directories (cd), printing the working directory (pwd), listing directory contents (ls), creating/deleting directories and files (mkdir, rmdir, touch, cp, rm, mv), and managing file permissions (chown, chgrp, chmod). It also covers commands for reading/writing text files (more, less, cat), finding files (find), identifying file types (file), counting lines (wc), and searching files (grep).
The document discusses Linux commands for file management, viewing and shell programming. It describes common commands like ls, cd, cp, mv, rm, mkdir which allow navigating and manipulating files and directories. It also covers commands for viewing file contents like cat, head, tail, grep. Commands for compression like tar, gzip, zip and decompression like gunzip, unzip are mentioned. The document also has a section on shell programming which explains how to write shell scripts using commands and variables. It provides examples of using pipes, redirections and command options.
cp command in Linux with examples
cp stands for copy. This command is used to copy files or group of files or directory. It creates an exact image of a file on a disk with different file name. cp command require at least two filenames in its arguments.
How to Connect Devices and Kitchen Printers in Odoo 17 POSCeline George
油
Odoo 17 POS introduces efficient product management through hierarchical categories. By organizing products into nested categories like "Food" or "Drinks," it enhances navigation and makes finding items easier.
PLAY: Types, value and selection of play material PLAY THERAPY.pptxPRADEEP ABOTHU
油
Play: Play is a fun and natural activity that children do on their own for enjoyment. It helps them grow and learn. Even adults can benefit from play in different ways. Play Therapy: Play therapy is a form of psychotherapy that helps children express their emotions, thoughts, and experiences through play. It is used to support their emotional and psychological well-being.
This document provides an overview of basic Linux commands for common file system tasks like navigating directories, managing files, and copying or moving files. It describes commands like pwd to print the working directory, cd to change directories, ls to list directory contents, mkdir to create directories, cat to view file contents, rmdir to delete empty directories, rm to delete files and directories, and cp and mv to copy and move files between locations.
The document provides 40 tips for using basic Linux command line commands and tricks. Some key points include: everything in Linux is a file; # and $ denote superuser and normal users respectively; Ctrl+Alt+F1-F6 switch between terminals while Ctrl+Alt+F7 switches to the GUI; tilde ~ denotes the user's home directory; hidden files start with a dot; ls -a views hidden files; file permissions use rwx notation; and variables can be assigned text for repeated use.
The document provides 40 tips for using basic Linux command line commands and tricks. Some key points include: everything in Linux is a file; # and $ denote superuser and normal users respectively; Ctrl+Alt+F1-F6 switch between terminals while Ctrl+Alt+F7 switches to the GUI; tilde ~ denotes the user's home directory; hidden files start with dot; ls -a views hidden files; file permissions use rwx scheme; and variables can store long text for repeated use.
This document provides summaries of common Linux commands, including ls, mkdir, cd, rmdir, rm, cp, mv, touch, echo, head, tail, less, more, grep, find, man, wc, pipe (|), cat, and mv. It describes the basic syntax and common examples for using each command to list, create, delete, copy, move, view, and filter files and directories from the command line.
The document provides descriptions of various Linux commands for basic usage and pentesting. It describes commands for making directories (mkdir), deleting empty directories (rmdir), viewing processes (ps), checking username (whoami), checking disk space (df), displaying date and time (date), checking connectivity (ping), downloading files (wget), looking up domain registration records (whois), navigating directories (cd), listing directory contents (ls), displaying command manuals (man), displaying text files (cat), copying files (cp), moving and renaming files (mv), removing files and directories (rm), creating empty files (touch), searching files (grep), using administrative privileges (sudo), viewing start of files (head), viewing end of files (
1. The document provides examples of common Linux commands and their usage including tar, grep, find, ssh, sed, awk, vim, diff, sort, export, xargs, ls, ifconfig, uname, ps, free, top, df, kill, rm, cp, mv, cat, mount, chmod, chown, passwd, mkdir, ifconfig, uname, whereis, whatis, and locate.
2. Examples shown include how to create, extract, and view tar archives, search files with grep, find files, login remotely with ssh, edit files with vim, compare files with diff, view processes with ps, check storage usage with df, terminate processes with kill, manage files
The document provides an overview of essential Linux commands and concepts, organized into sections on essential commands, command structure, help, moving around directories, reading and writing files, directories, moving and renaming files, copying and removing files, links, searching, ownership and permissions, switching users, and useful commands. Key commands covered include ls, cd, pwd, touch, mkdir, mv, cp, rm, chmod, and sudo. File permissions are explained using rwx notation and octal representation.
Linux is an open-source operating system based on Unix, designed for multi-user environments. The document provides an overview of basic Linux commands like ls, mkdir, cd for navigating files and directories, as well as more advanced commands for manipulating files, checking system resources, and getting system information. It also lists and describes many common Linux commands and their functions.
The document discusses Linux commands for file management and viewing. It describes commands for navigating directories (cd), changing file permissions (chmod), copying files (cp), finding files (find), listing directory contents (ls), creating and removing directories (mkdir, rmdir), moving and renaming files (mv), viewing file contents (cat, head, tail), comparing files (cmp, diff), searching files (grep), and more. It also covers commands for compressing, archiving, and backing up files like tar, gzip, zip, and commands for counting, sorting, and filtering file contents.
This document provides an overview of common UNIX commands for navigating directories, listing files, editing text, searching for files and strings, compressing files, and more. It describes commands like ls, cd, pwd, vi, grep, find, tar, gzip and man for viewing manual pages. It also explains concepts like pipes, redirection, environment variables and basics of the awk command for text manipulation.
Linux is an open source operating system initially created by Linus Torvalds in 1991. It has since grown significantly with hundreds of companies and individuals developing their own versions based on the Linux kernel. The kernel is developed under the GNU GPL license and its source code is freely available. Basic Linux commands allow users to navigate directories, manage files and permissions, transfer files, and get system information. More advanced commands provide additional control and functionality.
The document provides an overview of common Linux commands, including commands for executing other commands, navigating directories, listing and copying files, managing users and permissions, searching for files, processing text, managing archives, and compressing files. Examples are given for commands like ls, cd, cp, mv, rm, who, echo, alias, awk, chown, diff, grep, pushd, kill, df, cat, tar, gzip, su. Brief descriptions are provided for most commands and references are given at the end for additional Linux resources.
This document provides an introduction to Linux, including:
- What Linux is and where it came from, as an open source operating system created by Linus Torvalds in 1991.
- How to get Linux through downloading a distribution like Red Hat and the packages it includes.
- Why Linux has become significant due to its growing popularity, ability to run on multiple hardware platforms, and being free.
- An overview of Linux commands and utilities for file management, processes, users and permissions.
This document provides an overview of basic Unix commands including ls, cd, pwd, mkdir, rm, rmdir, cp, find, touch, echo, cat, who, and du. It explains what each command is used for and provides examples of common usages. The document serves as a beginner's guide to learning Unix commands.
The document provides an overview of 11 common UNIX commands used in the Mac terminal: ls, cd, pwd, mkdir, rm, mv/cp, who, cat, sudo, control+C, and clear. It describes what each command does and provides examples of basic usage. The document explains that while the Mac OS is based on UNIX, Windows uses different DOS commands that are not compatible. It encourages users to get familiar with UNIX commands to expand their coding skills.
The document provides an overview of common Unix commands for navigating directories, managing files, and examining file contents. It discusses commands for changing directories (cd), printing the working directory (pwd), listing directory contents (ls), creating/deleting directories and files (mkdir, rmdir, touch, cp, rm, mv), and managing file permissions (chown, chgrp, chmod). It also covers commands for reading/writing text files (more, less, cat), finding files (find), identifying file types (file), counting lines (wc), and searching files (grep).
The document discusses Linux commands for file management, viewing and shell programming. It describes common commands like ls, cd, cp, mv, rm, mkdir which allow navigating and manipulating files and directories. It also covers commands for viewing file contents like cat, head, tail, grep. Commands for compression like tar, gzip, zip and decompression like gunzip, unzip are mentioned. The document also has a section on shell programming which explains how to write shell scripts using commands and variables. It provides examples of using pipes, redirections and command options.
cp command in Linux with examples
cp stands for copy. This command is used to copy files or group of files or directory. It creates an exact image of a file on a disk with different file name. cp command require at least two filenames in its arguments.
How to Connect Devices and Kitchen Printers in Odoo 17 POSCeline George
油
Odoo 17 POS introduces efficient product management through hierarchical categories. By organizing products into nested categories like "Food" or "Drinks," it enhances navigation and makes finding items easier.
PLAY: Types, value and selection of play material PLAY THERAPY.pptxPRADEEP ABOTHU
油
Play: Play is a fun and natural activity that children do on their own for enjoyment. It helps them grow and learn. Even adults can benefit from play in different ways. Play Therapy: Play therapy is a form of psychotherapy that helps children express their emotions, thoughts, and experiences through play. It is used to support their emotional and psychological well-being.
Financial Forms, Awards & Appeals for Families & CounselorsCyndy McDonald
油
How can families maximize financial awards & pursue appeals? What happens once financial aid forms land at the college? Learn directly from financial aid officers what goes into award committee decisions & how financial aid offers are made. Discuss how to compare aid offers, and the correct way to approach appeals.
#cyndyfridayforums #cyndymcdonald #financialaid #collegeadmissions #collegecounseling
By the end of this session, participants will be able to:
Understand the PRISMA Guidelines Explain the purpose and key components of the PRISMA checklist and flow diagram in systematic review reporting.
Identify Common Pitfalls Recognize frequent errors and challenges in reporting systematic reviews and how they impact transparency and reproducibility.
Apply Best Practices Implement strategies to enhance the clarity, completeness, and accuracy of systematic review reporting.
Use PRISMA Effectively Utilize PRISMA tools and resources to improve the structure and presentation of systematic reviews.
Assess PRISMA Compliance Critically evaluate published systematic reviews for adherence to PRISMA guidelines.
More Than Both Sides Redefining Objectivity March 2025.pdfLogan Aimone
油
Objectivity has been the gold standard in journalism. But whose objectivity? The traditional definition of objective must evolve beyond detached stenography and performative balance journalists must be truth tellers. Learn how increasing standards of fairness and transparency can improve credibility and trust.
Software Engineering and Traditional Software development modelsNitinShelake4
油
Introduction to Software, Product vs. Process, Nature of Software and Process, Software Engineering Practice, SDLC.
Process Models: Waterfall Model, V-Model, Incremental Model, Evolutionary Models, RAD models.
New Widget to Record Invoice Line Description Odoo 18Celine George
油
As we know, Odoo launches every new version with a wide variety of changes both functional and technical so far. Likewise, in Odoo 18 also, there are a lot of new features which can fulfill the needs of the users adequately. In this slide, we are going to discuss a new feature added to Odoo 18s Invoice line description.
Choosing the Right Marketing Technology Stack for Your Nonprofit.pdfTechSoup
油
n this webinar, Tapp Network experts taught an in-depth exploration of the latest marketing technology tools to guide you through selecting and integrating the right platforms to enhance your organizations efficiency, engagement, and overall impact.
APM event hosted by the Wessex Network on 6 March.
Speakers: Martin Paver and James Garner
An evening of ground-breaking discussion on how next-generation project delivery is set to disrupt the traditional methods of project management. From risk management to PMOs, we explored the tension between refining old methods and completely reimagining them. An interactive conversation with the audience.
We explored why sticking to outdated practices can hinder progress and how embracing new technologies like AI and advanced data analytics can revolutionise the field. We challenged the conventional wisdom that has dominated project management for decades and highlight the pitfalls of resisting change. This session provided insights into how adopting innovative approaches can lead to more efficient, adaptive, and successful project outcomes. Whether you are a seasoned project manager or new to the field, this event should have provoked thought and inspired you to rethink your strategies. Plus, we showed you a path to futureproof your career.
Don't miss this opportunity to be at the forefront of the project management revolution with some of the leading minds on the subject.
We delved into 2 recent open source books on Next Generation PMOs and Next Gen Risk Management which are successfully challenging established norms and seeding a movement. We also showcased some of the latest developments and demonstrate that we have transitioned from sci-fi to making this a reality.
Attendees gained insights into how these cutting-edge techniques can lead to more efficient, adaptive, and successful project outcomes.
Useful Link:
https://www.apm.org.uk/news/next-gen-project-delivery-disrupting-the-status-quo/
Fuel Injection in Compression Ignition EngineNileshKumbhar21
油
Requirements of injection system, Types of injection systems Individual pump, Common rail and Distributor systems, Unit injector, Types of fuel nozzles- single hole, multi hole, pintle, and pintaux, Electronic diesel injection system.
How to Simplify Reconciliation Process using Reconciliation Models using odoo...Celine George
油
In a firm, daily transactions are invoiced, but the accounting department may not enter all details immediately. Weekly, account statements are reviewed for reconciliation, ensuring accuracy and transparency by comparing cash transactions with bank records.
Kothari Commission Recommendations And Their Implementation.pptxDr. JN Gorai, PhD
油
Mind Map
Introduction to Kothari Commission
Key Objectives of the Commission
Key Objectives of the Commission
Recommendations on Higher Education
Vocational Education and Training
Educational Structure and System
Meaning, Objectives and Limitations of Financial Statement Analysis. , Tools for Financial
Statement Analysis , Balance Sheet: Vertical Balance Sheet (Simple Numerical) , Comparative
Statement: Introduction, Methods and Steps for Preparation (Example of Simple Statement ) ,
Common Sized Statement: Introduction, Methods and Steps for Preparation(Example of Simple
Statement ) , Cash Flow Statement: Importance Steps for Preparation & Use (Example of
Simple Statement ) , of Accounting Ratios: Meaning, Objectives and Classification
How to Configure Authorized Signatory on Invoice in Odoo 18Celine George
油
Odoo 18 Sign allows you to send, sign, and approve documents online, using electronic signatures. An electronic signature shows a persons agreement to the content of a document. Just like a handwritten signature, the electronic one represents a legal binding by the terms of the signed document.
How to Configure Authorized Signatory on Invoice in Odoo 18Celine George
油
Linux_Commands.pdf
1. Linux Commands
Yakinur Rahman
July 2023
Introduction
Can know background details using the command line.
Before diving into the command lines we need to know two things first.
1. Shell:Is a program that takes command from the keyboard and gives
them to the operating system to perform.
2. Terminal:Is a tool where you can pass your shell command.
Type wsl in cmd to go to linux terminal.
File System
1. Hierarchical Directory Structure
2. It uses Root directory.
3. Root folder starts from /
Commands
1. pwd Command: To know where I am.
2. clear Command: To clear the terminal.
3. cd Command: To change the directory.
If use cd you will change to home directory.
To go to root folder use cd /.
To change to home directory use cd
1
2. To get back to the previous folder or one folder
above use cd ..
To go to a directory use cd [path]
When going to a directory named with white
space like My books use cd My books or
cd Mybooks or cd My books but not cd
My books.
4. ls Command: Shows the list of all the files and
directories in the current folder.
The syntax is ls [options][files or directory].
If we write ls filename/ we will see the directory
content in that file. For the root folder, it is ls /.
For the list of files and directories in the home
folder use ls .
To go back to the previous directory we use ls
... To go back two directory we use ls ../...
To get the list of directories in long format(detail
of the files and directories) use ls -l.
To know the hidden files also use ls -a. To get
2
3. the hidden files in the long format use ls -al.
To get the file list in long format and in sorted
order according to size use ls -lS.
And if you want sorted according to name use
ls -ls.
To get all the .c files in home/yakin use ls home/yakin/*.c
And to get all the files with whatever extension
in home/yakin use ls home/yakin/*.*
If I want to save the output of ls command in
a file I use ls -lS > out.txt
To get only the directories, use: ls -d */
T see a directory structure use : ls -R
To know more about ls command use: man ls
5. cat command: It has three relative functions
with regard to the text files.They are:
(a) Displaying the text files
(b) Combining copies of text files
(c) Creating new text file
Syntax of using cat command is : cat options
file1 file2 ...
If we use cat and then type hello world the
output will be hello world
3
4. To get out of cat command use ctrl+d
To display the contents of a text file use cat file-
name.txt
Adding line number to each non-blank line in the
file use cat -b filename.txt
To add line number to all the lines in the file
use cat -n filename.txt
To display all the lines in a file with a single line
gap between the lines(if had multiple blank lines)
use cat -s filename.txt
To add dollar symbol at the end of each line use
cat -E filename.txt
To know more about cat command use man cat
To write to a file use cat > filename.txt, then
type whatever you want in the file.Use ctrl+d
to get out of cat command. Then use cat file-
name.txt to be sure what you wrote were per-
sistent or not.
If we write anything that overrides the previous
contents again, use cat > filename.txt.
If you dont want to override but append then
4
5. use cat >> filename.txt.
To copy the contents of files to another file use
cat filename1 filename2 ... > destination-
filename
To append files to a file use cat filename1 file-
name2 ... >> destinationfilename
6. mkdir command:
It is make directory command.
To create a directory, use mkdir directoryName
To create a subdirectory in a directory, use mkdir
dirName/subDirName. If dirName dont ex-
ist than it will show No such file or directory.
To creat directory with subdirectory use mkdir
-p dirName/subDirName.
To create a list of subdirectory in a directory use
mkdir -p dirName/{subDirName1,subDirName2,...}
.Remember subdirectory names should be sepa-
rated by ,(comma) and there cant be any space
before and after comma.
7. rmdir command:
5
6. Remove directory command.Syntax of rmdir com-
mand is :
rmdir options directoryName
To remove a directory, use rmdir dirName
To remove a subdirectory use rmdir dirName/subdir1/.../subdirN.
Using the command you will remove subdirN. To
check use ls -R
To remove the whole directory structure, use rmdir
-p dirName/subdir1/.../subdirN. Check the
result using ls -R.
To know how rmdir command is working in the
background on a directory structure like a/b/c/d/e
use rmdir -pv a/b/c/d/e
Now for your kind information rmdir command
will not work if the directory is not empty. Like,
if the directory contain any .txt, .c, .html file,
etc. And to accomplish it use rm command.
8. rm command:
It is remove command.
To delete a directory together with its files use
rm -r structureOfTheDirectory.Suppose, a
directory is a/b/c/d/e and b contains a text file
like test.txt then using rmdir -p a/b/c/d/e
will remove c,d, and e from the directory struc-
6
7. ture. To remove b and its file use rm -rv a/b, it
will also who whats happening behind. You will
have only directory a. Instead of using rm -rv
a/b you could have used rm -rv a.To delete the
structure altogether.
9. cp command:
It is copy command. Used for copying files and
directories.The syntax of this command is
cp options source destination
If used cp file1.txt file2.txt, then it will copy
file1 to file2. If file2 does not exist, then it will
create file2.
If I want to have a copy of a file in a directory,
then use cp fileName1 fileName2 directory-
Name.Now fileName1 and fileName2 will have a
copy in the directoryName. It will override any
existing file.
To know is the cp command overriding anything
or not use cp -i fileName1 fileName2 direc-
toryName. If you enter y it will override, else
if you enter n then it will not override.
If we are in a subdirectory, but want to copy file
from the directory, use cp ../fileName . . cp is
the command. .. is used to go up the directory.
And the last . indicates the current directory.
7
8. To copy file to a directory cp filePath direc-
toryPath.
To copy the contents of a directory to another
directory and to create the destination directory
use cp -R direct1 direct2. The contents of di-
rect1 will be copied to direct2.
If the direct2 already exists a copy of direct1 will
also be in direct2.To observe use cp -vR direct1
direct2
For more details use man cp
10. mv command:
Used to change the name of a file or directory.
Syntax is
mv options source destination, source and
destination are files or directories.
If you want to move a file named test.txt to yakin/
directory use mv test.txt yakin/
If test.txt already exists in yakin/ directory, then
using mv test.txt yakin/ will override the al-
ready existing one.
If you want to prevent the overriding, use mv
8
9. -i test.txt yakin/
If you want to move a directory suppose yakin/
into another directory, suppose family/ then use
mv yakin family. But the condition is both
directory exists. Otherwise, it will just rename
yakin/ directory to family/ directory.
To know more about this command use man mv
11. less command:
Used to find something (word|pattern) in a file.
When having a large size of text, if you want
to read from the start use less big.txt, if the
file name is big.txt.Press the up arrow and down
arrow to read.
If you want to read page by page instead of line
by line, use space to down instead of down-
arrow and b instead of up-arrow.
To reach the END of the file, use Shift+G.
To reach the TOP press g.
To search for something, press / and then type
the word. After typing the word use ENTER.It
will get you the first occurrence of the word. To
9
10. go to the next occurrence, press n.
If you want to search the word from the END
of the file, press ?, then type the word. If you
press n you will get the occurrences from bot-
tom to top.
To exit less command press q.
To know more use man less
12. touch command:
Used to create new empty files in Linux. Also
used to change the timestamps of directories.
To create an empty file, use touch filename-
WithExtension You can create files only using
touch command.
To change the timestamp of the already existing
file to the current time, use touch filename-
WithExtension
13. nano command:
Nano is a useful and friendly text editor.It has
many features.
To create a new file : nano filename.extension
10
11. File will not be created, until saved.
You can write programs too. For example, nano
hello.cpp
14. sudo command:
sudo command provides us administrative privi-
leges. When we want to install any third-party
software we need this command.
To install gcc , use sudo apt-get install gcc
To install g++ , use sudo apt-get install g++
To get to super user mode, use sudo -s
15. top command:
Provides dynamic view of the running system.
Used to know which program is using more re-
sources.
To know which program is using how much re-
sources, enter top. PID refers to process id.
By default, after every 3 seconds the view is re-
freshed.
11
12. To change the refreshing time, press s when the
view after top is screening.
To filter out idle processes or to screen active
processes, press i.
To kill a process, press k. Then input the pro-
cess id.Or, PID.
An alternative is ps -ux.
If you want to know all the processes under a
userName then use ps -U userName
16. kill command:
It is used to kill processes. The syntax is:
kill -flags PID
To know the PID of a process, use pidof pro-
cessName
Then use kill PID to kill the process.
If you were not able to kill use this command
instead kill -KILL PID
Or, you can use kill -9 PID too.
12
13. 17. echo command:
Displays anything you write after the echo com-
mand.The echo command is important when script-
ing.
To do the echo use echo statement Or, echo
statement
var=Hello, no space before and after = sign.Then
use echo $var, and you will be displayed Hello.
Or, x=10 then use echo The value of x is
$x. This will display what you are thinking.
If you use echo -e Some text then the
escape character will be enabled. And this will
print: Some ext. If used echo Some
text then it would have printed: Some text.
18. chmod command:
Here instead of filename, you can use directory-
Name. The function is the same.
chmod o+[x|r|w] filename will grant to ex-
ecutable or read or write permission to others on
a file.
chmod o-[x|r|w] filename will sack executable
or read or write permission of others on a file.
13
14. Use ls -l to confirm these operations.
chmod g+[x|r|w] filename these will grant ex-
ecutable or read or write permission to groups on
a file.
chmod g-[x|r|w] filename these sack executable
or read or write permission of groups on a file.
chmod ug=[x|r|w] filename used to give per-
mission to both user, group, and everyone on a
file. Remember, no space before and after of =.
To remove all the permissions use chmod a-
[x|r|w] filename
To give permission to all, use chmod a+[x|r|w]
filename
To specifically give permission to user,group and
others, use chmod u[+|-][x|r|w],g[+|-][x|r|w],o[+|-
][x|r|w] filename.
Octal and Numerical Permissions: Remem-
ber (u,g,o) can be of combinations like([r|w|x],[r|w|x],[r|w|x]).
So, u can be expressed as a 3-bit combination.
100 means granting reading privileges to the user,
and 111 means granting all privileges to the user.
The same is applied to groups and others. 100 in
binary represents 4 in octal and 111 represents 7
14
15. in octal. Now, if you use chmod 000 filename
then you give no permissions to anyone. But if
you use chmod 700 filename then you provide
all permissions to the user but nothing to groups
and others.
I/O Redirection
Redirection simply means capturing output from a file or command or
program and sending it into another file or command or program as an
input. If we want to send output to a file use output > file . Now use
cat5 command to do it.
File/Directory Permission:
The r stands for read, w stands for write, d stands for directory, and
x stands for executable. Use chmod18 command to change the file per-
mission.
Bash Scripting:
A script is a text file that contains a sequence of commands for an op-
erating system. Create a script file using nano myscript1.sh. And we
need to know where our bash is. Then type #! [location of the bash].
To know where the bash is, use which bash. So, now write the com-
mands you want in the myscript1.sh file.If permission is already given,
use ./myscript1.sh to do the execution.
15