This document provides an overview of Linux file management basics. It discusses permissions for files and directories, essential file management tasks like creating/moving/copying files, using text editors like Nano and Vim, performing operations like viewing file timestamps and disk usage. It also covers Linux wildcards for pattern matching, and tools for finding files like locate, find, whereis etc. I/O redirection and pipes/filters are also mentioned.
we need to have a good amount of basic or in-depth knowledge on Linux Basics. This will help one's job easy in resolving the issues and supporting the projects.
Are you a system admin or database admin? Or working on any other technology which is deployed or implemented on linux/UNIX machines? Then you should be good with Linux basic concepts and commands. We will cover this section very clearly.
Getting started with setting up embedded platform requires audience to understand some of the key aspects of Linux. This presentation deals with basics of Linux as an OS, Linux commands, vi editor, Shell features like redirection, pipes and shell scripting
Course 102: Lecture 26: FileSystems in Linux (Part 1) Ahmed El-Arabawy
This lecture introduces some concepts about FileSystems in Linux.
Video for this lecture on youtube:
http://www.youtube.com/watch?v=9jj1QOokACo
Check the other Lectures and courses in
http://Linux4EnbeddedSystems.com
or Follow our Facebook Group at
- Facebook: @LinuxforEmbeddedSystems
Lecturer Profile:
Ahmed ElArabawy
- https://www.linkedin.com/in/ahmedelarabawy
we need to have a good amount of basic or in-depth knowledge on Linux Basics. This will help one's job easy in resolving the issues and supporting the projects.
Are you a system admin or database admin? Or working on any other technology which is deployed or implemented on linux/UNIX machines? Then you should be good with Linux basic concepts and commands. We will cover this section very clearly.
Getting started with setting up embedded platform requires audience to understand some of the key aspects of Linux. This presentation deals with basics of Linux as an OS, Linux commands, vi editor, Shell features like redirection, pipes and shell scripting
Course 102: Lecture 26: FileSystems in Linux (Part 1) Ahmed El-Arabawy
This lecture introduces some concepts about FileSystems in Linux.
Video for this lecture on youtube:
http://www.youtube.com/watch?v=9jj1QOokACo
Check the other Lectures and courses in
http://Linux4EnbeddedSystems.com
or Follow our Facebook Group at
- Facebook: @LinuxforEmbeddedSystems
Lecturer Profile:
Ahmed ElArabawy
- https://www.linkedin.com/in/ahmedelarabawy
Users and groups are used on GNU/Linux for access control that is, to control access to the system's files, directories, and peripherals. Linux offers relatively simple/coarse access control mechanisms by default.
Unix , Linux Commands
Unix, which is not an acronym, was developed by some of the members of the Multics team at the bell labs starting in the late 1960's by many of the same people who helped create the C programming language.
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...Edureka!
This Linux Tutorial will help you get started with Linux Administration. This Linux tutorial will also give you an introduction to the basic Linux commands so that you can start using the Linux CLI. Do watch the video till the very end to see all the demonstration. Below are the topics covered in this tutorial:
1) Why go for Linux?
2) Various distributions of Linux
3) Basic Linux commands: ls, cd, pwd, clear commands
4) Working with files & directories: cat, vi, gedit, mkdir, rmdir, rm commands
5) Managing file Permissions: chmod, chgrp, chown commands
6) Updating software packages from Linux repository
7) Compressing & Decompressing files using TAR command
8) Environment variables and Regular expressions
9) Starting and killing processes
10) Managing users
11) SSH protocol for accessing remote hosts
A File Structure should be according to a required format that the operating system can understand.
A file has a certain defined structure according to its type.
A text file is a sequence of characters organized into lines.
A source file is a sequence of procedures and functions.
An object file is a sequence of bytes organized into blocks that are understandable by the machine.
File Type
File type refers to the ability of the operating system to distinguish different types of file such as text files source files and binary files etc. Many operating systems support many types of files. Operating system like MS-DOS and UNIX have the following types of files −
Ordinary files
These are the files that contain user information.
These may have text, databases or executable program.
The user can apply various operations on such files like add, modify, delete or even remove the entire file.
Directory files
These files contain list of file names and other information related to these files.
Special files
These files are also known as device files.
These files represent physical device like disks, terminals, printers, networks, tape drive etc.
Problemas de mala vecindad, incompleta infraeastructura básica y equipamiento urbano son algunas de las quejas de los habitantes de las cooperativas Socio Vivienda 1 y 2.
Users and groups are used on GNU/Linux for access control that is, to control access to the system's files, directories, and peripherals. Linux offers relatively simple/coarse access control mechanisms by default.
Unix , Linux Commands
Unix, which is not an acronym, was developed by some of the members of the Multics team at the bell labs starting in the late 1960's by many of the same people who helped create the C programming language.
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...Edureka!
This Linux Tutorial will help you get started with Linux Administration. This Linux tutorial will also give you an introduction to the basic Linux commands so that you can start using the Linux CLI. Do watch the video till the very end to see all the demonstration. Below are the topics covered in this tutorial:
1) Why go for Linux?
2) Various distributions of Linux
3) Basic Linux commands: ls, cd, pwd, clear commands
4) Working with files & directories: cat, vi, gedit, mkdir, rmdir, rm commands
5) Managing file Permissions: chmod, chgrp, chown commands
6) Updating software packages from Linux repository
7) Compressing & Decompressing files using TAR command
8) Environment variables and Regular expressions
9) Starting and killing processes
10) Managing users
11) SSH protocol for accessing remote hosts
A File Structure should be according to a required format that the operating system can understand.
A file has a certain defined structure according to its type.
A text file is a sequence of characters organized into lines.
A source file is a sequence of procedures and functions.
An object file is a sequence of bytes organized into blocks that are understandable by the machine.
File Type
File type refers to the ability of the operating system to distinguish different types of file such as text files source files and binary files etc. Many operating systems support many types of files. Operating system like MS-DOS and UNIX have the following types of files −
Ordinary files
These are the files that contain user information.
These may have text, databases or executable program.
The user can apply various operations on such files like add, modify, delete or even remove the entire file.
Directory files
These files contain list of file names and other information related to these files.
Special files
These files are also known as device files.
These files represent physical device like disks, terminals, printers, networks, tape drive etc.
Problemas de mala vecindad, incompleta infraeastructura básica y equipamiento urbano son algunas de las quejas de los habitantes de las cooperativas Socio Vivienda 1 y 2.
Powerful and efficient tool leveraging UNIX commands for streamlined automation, enabling seamless execution of complex tasks and maximizing productivity.
Workshop on command line tools - day 1Leandro Lima
Slides of the I Workshop on command-line tools with the collaboration of CAG (Center for Applied Genomics - Children's Hospital of Philadelphia) bioinformatics analysts.
1st day
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Let's dive deeper into the world of ODC! Ricardo Alves (OutSystems) will join us to tell all about the new Data Fabric. After that, Sezen de Bruijn (OutSystems) will get into the details on how to best design a sturdy architecture within ODC.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
I have heard many times that architecture is not important for the front-end. Also, many times I have seen how developers implement features on the front-end just following the standard rules for a framework and think that this is enough to successfully launch the project, and then the project fails. How to prevent this and what approach to choose? I have launched dozens of complex projects and during the talk we will analyze which approaches have worked for me and which have not.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
2. Contents
Permissions
File permission
Directory permission
Essential File Management Tasks
Create/Move/Copy/Rename/Delete
Using Text File Editors
Nano, Vim, Sublime, Emacs
Working with Nano and Vim
More File operations
stat, touch, file, wc, du, df, diff
Linux Wildcards & Pattern matching
Finding Files
locate, find, whereis, which, whatis
I/O Redirection, Pipes and Filters
Using Common Text Manipulation Tools (tail, head, tr, tee)
Working with grep, egrep
3. Permissions
Permissions are the rights to act on a file/directory
Owners assign permission on every file/directory
Permissions are important to create a secure environment
What they are :
r : only open and view file/directory contents
w : modify file/directory contents
x : execute or run the file if it is a program or script
- : no read, write or execute permissions set on file/directory
= : make it the only permission
Permissions are specified for three sets of people[identities]:
owner [u] - a single person who owns the file. (typically the person who created the file but ownership may be
granted to some one else by certain users)
group [g] - every file belongs to a single group
others/all [o] [a] - everyone else who is not in the group or the owner
Note: Linux/UNIX OS has ability to multi-task and to have multiple users, who can have access to system
simultaneously, a method to protect users from each other is required. This is where permissions
come to play.
4. Format of setting Permissions
Octal Decimal Permission Representation
000 0(0+0+0) No Permission - - -
001 1(0+0+1) Execute - - x
010 2(0+2+0) Write - w -
011 3(0+2+1) Write + Execute - w x
100 4(4+0+0) Read r - -
101 5(4+0+1) Read + Execute r - x
110 6(4+2+0) Read + Write r w -
111 7(4+2+1) Read + Write + Execute r w x
drwxr-xr-x -rw-r--r--
Difference between a Directory and File Permissions:
The first character identifies the file type : dash ( - ) indicates a normal file and d denotes it is a directory.
5. Working with Permissions
View Permissions – ls -l [path/to/directory/file]
ls -l /home/juno/linuxtutorial/test.txt
ls -ld /home/juno/linuxtutorial
Change permissions – chmod [permissions] [path]
chmod : change file mode
chmod has permission arguments that are made up of 3 components:
changing the permission for [ugoa] - user (or owner), group, others, all
granting or revoking the permission - indicated with either a plus ( + ) or minus ( - )
Which permission are we setting? - read ( r ), write ( w ) or execute ( x )
Examples:
chmod g+x test.txt
chmod u-w test.txt
chmod ugo+wx test.txt
chmod 777 test.txt
chmd 240 test.txt
6. Permissions for Directories
The same series of permissions may be used for directories but they
have a slightly different behavior:
r - user has ability to read directory contents (i.e., do an ls)
w - user has ability to write into the directory (i.e., create files and directories)
x - user has ability to enter that directory (i.e., cd)
7. Essential File Management Tasks
Creating a new Directory using CLI
mkdir : command to creates directories as a superuser
Syntax:
mkdir [option] [Directory_Name]
sudo mkdir mydir (creates a new directory whose parent is the current directory) OR
mkdir [option] [/home/path/to/Directory_Name]
sudo mkdir /home/juno/mydir
Options:
-m : Creates the mydir directory, and set its permissions
sudo –m a=rwx mydir
-p : mkdir will first create the parent directory /home/juno/a/b if it does not already
exists
mkdir -p /home/juno/a/b/c
rmdir : Removes empty directories – sudo rmdir /home/juno/a
8. Creating a new File using CLI
touch : touch sample.txt
> sample.txt
cat > sample.txt
9. Naming [File/Directory] Conventions
A directory may have the same name as one of the items it contains
Different directories may contain files with same name
Some characters have special meanings to Unix hence it is best to avoid
using these characters in file names:
/ " ' * | ! ? ~ $ < >
Unix is case-sensitive : so each of these is a unique file: myfile, Myfile,
myFile, and MYFILE
11. 1. Using Text File Editors - Nano
Nano:
-c : open file showing number of lines : nano -c test.txt
File Controls
nano FILE.txt : Open or create the file
Ctrl-o Y : Enter Save changes
Ctrl-r Alt-f : Open a new file with a new buffer
Alt-> : Switch to the next file buffer
Alt-< : Switch to the previous file buffer
Ctrl-x : Quit nano
Navigating through file contents
Ctrl-a : Move to the beginning of the current line
Ctrl-e : Move to the end of the current line
Ctrl-v : Move down one page
Ctrl-y : Move up one page
Alt- : Go to the beginning of the file
Alt-/ : Go to the end of the file
Alt-g : Go to a target line number
Alt-a Alt-} : Select a block and indent the block
Alt-a Alt-{ : Select a block and outdent the block
12. 1. Using Text File Editors - Nano (contd…)
Copy and Paste
Alt-a : To select a block for copy or cut operation, do Alt-a again to unselect
Alt-a Alt-^ : Copy a highlighted block to the clipboard
Alt-a Ctrl-k : Cut a highlighted block to the clipboard
Ctrl-k : Cut from the current cursor position to the end of the current line
Ctrl-u : Paste the contents from the clipboard at the current cursor position
Search and Replace
Ctrl-w : Search for a target string
Alt-w : Repeat the last search
Alt-r : Search and replace
13. 2. Using Text File Editors - Vim
Vim:
CLI Options : vim -R text.txt
-R : Read-only mode (like "view")
-M : Modifications in text not allowed
-p and -o : open new tabs or windows at run time
+ : start at end of file
+<lnum> : (+5) start at line <lnum>
File Control
vim test.txt : Open the file specified with vim in command window
vim File1.txt File2.txt : Open two files simultaneously
ESC :next : go to the next file
ESC :previous : go to the previous file
ESC :tabe : file3.txt - Open a new file while vim is already opened with one file, if the file doesn’t exist, it will create it
ESC :tabn : or ESC :tabp : go to the next file or previous file accordingly
ESC :wqa : to save works in all tabs and quit vim
ESC :bd : to close the file without quitting the vim
ESC :w backup.txt : save the current file to a new file with the file name “backup.txt”
ESC :w : Save changes
ESC :wq: Save the changes and exit
ESC :q! : Quit without save
Edit mode or Insert mode
ESC i : Enter insert mode and start editing
14. 2. Using Text File Editors - Vim (contd…)
Line Control:
ESC 0 or ESC Home : move the cursor to the beginning of the current line
ESC $ or ESC End : move the cursor to the end of the current line
ESC :34 : go to line 34
ESC gg : go to the beginning of file
ESC G : go to the end of file
ESC ( : jump backward one sentence
ESC ) : jump forward one sentence
ESC dd : delete the current line
Cursor Control
h : Move Left
l : Move Right
j : Move Down
k : Move Up
Screen Control
ESC zt, zz, zb : move cursor to the Top, Middle, and Bottom of the screen respectively
ESC ctrl-f : Scroll down one screen page
ESC ctrl-b : Scroll up one screen page
Vim Undo and Redo
ESC u : Undo the changes
ESC Ctrl-r : Redo the changes
15. 2. Using Text File Editors - Vim (contd…)
Search and Replace
ESC /sometext and enter : Search for the word specified.
n : To find the next occurrence
N : the previous occurrence
ESC :s/foo/bar/g : search and replace “foo” with “bar” in the current line
ESC :%s/foo/bar/gc : search and prompt to replace “foo” with “bar”
ESC :%s/foo/bar/g : search and replaces all “foo” with bar in the file
ESC :%s/[0-9]/a/g : find all digits and replaces it with “a”.
Copy and Paste
ESC v : move the cursor to select the text to cut or copy
Press d : to cut OR
Press y : to copy
Press p : Move cursor to the point to paste the text and Press p to paste it
Reveal hidden Characters
:set list
:set nolist
Help
ESC :help : open help page
ESC :q : exit help page
16. More File Operations
Viewing file timestamps : using touch command
Different types of timestamps are associated with files e.g., access timestamp, modification
timestamp etc.
state test.txt
touch : command is used to change timestamps associated with a file :
touch -d "2013-01-10 10:00:07" -a test.txt :
-d : use specified time instead of current time
-a : change only the access time
touch -d "next saturday" -m test.txt - -m : changes file modification time
touch -d “5 hours ago" -a test.txt
Determine file types : using file command
file test.txt – view type of a specified file
file * : view type of all files in current directory
Print the number of new lines, words, and bytes in files: using wc command
wc test.txt OR wc -l -w -c test.txt where -l, -w, and -c represent line words and byte counts
respectively
17. More File Operations (contd….)
Display disk usage of files and directories: using du command
du -h test.txt : -h : CLI option produces output in human readable format
du -s test.txt : -s : display the combined size of a directory and its subdirectories
du -S somedirectory : -S : display separate sizes
df -h test.txt : display the amount of disk space available on the file system containing a specific file or directory
df -h : shows disk usage for all the file systems
Compare two files: using diff command
diff : The command requires two filenames as arguments
diff FILE1 FILE2
%< lines from FILE1
%> lines from FILE2
%= lines common to FILE1 and FILE2
c : changed, d : delete, a : add
The command examines both files and produces output in a particular format to let the user know what changes are
required to be made for the files to match.
18. Linux Wildcards & Pattern matching : *?[ ]
A wildcard is a character that can be used as a substitute for any class of
characters to create a “pattern” to be used in a search in order to greatly increase
the flexibility and efficiency of search
Star/asterisk (*) Wildcard : It represents zero characters, all single characters or any string, in
other words, it represents everything
ls *.txt : list down all files having .txt extension
ls n* : list all files starting with lower case letter n
rm *enw* : delete all files in a current directory having e n or w as part of their name
file * : lists type of all file system objects in current directory
wildcards can be used at any point in the path
ls -lh /home/*/.bash_history : list .bash_history file in every users home directory
Question-mark (?) Wildcard : represents exactly a single character
ls *.???
file ?.*
ls ?i*
mv public_html/*.??g public_html/images/ : move all files of type either jpg/png into another directory
19. Linux Wildcards & Pattern matching (contd...)
Square Brackets Wildcard [] : represents a range of characters
file *[xyz]* : lists all objects in the current directory that have an x, y and/or z in them
ls *.[xyz]* : list all files that have an extension that begins with x, y or z
file [a-f]* : hyphen indicates a range inclusive of these two characters - this command would provide
information about all of the objects in the current directory that begin with any letter from a through f
file *[0-9]* : provide information about every object in the current directory whose name includes at
least one numeral
file [a-cx-z]* : specifies multiple sets of ranges - this command would return information about all
objects whose name begin with the first three or the final three lower case letters
ls jones[0-9][0-9][0-9] : succession of square bracket wildcards – this command would display all
filenames in the current directory that consist of jones followed by a three-digit number
ls [^a-k]* : caret ( ^ ) reverses the range, which means look for any character which is not one of the
range
20. Finding Files - Locate
Locate : the quickest way to find the location of files/directories
locate [options] name(s)
When used without any options, locate displays every absolute pathname for which the user
has access permission that contains any of the names of files and/or directories that are
provided to it as arguments
locate sysctl.conf, locate updatedb.conf locate mlocate.db
Options :
-o : display all the output in one line
-c : get the count of number of matching entries
-i : perform case insensitive search
-e : check if the file is physically present in the system
-l <num> : restrict search results
Note: The ‘locate’ command is fast as it searches for file paths in a database named “mlocate.db” rather than searching from
the entire hard drive. This database is automatically updated on a regular basis by cron, which runs in background and updates
this database file at a pre-configured frequency. Hence “updatedb” command is used to manually update mlocate.db file in
order to get latest and reliable results.
21. Finding Files - Find
Find : The find command searches out live file-system for files that match the search criteria
The find command syntax is:
find /where/to/look/up criteria action OR
find /dir/path/look/up criteria action OR
find /dir/path/look/up -name "dir-name-here“ OR
find /dir/path/look/up -name "pattern“ OR
find /dir/path/look/up -name "dir-name-here" -print OR
find /dir/path/look/up -name "dir-name-here“ OR
find / -name "dir-name-here“
Searching through the root file system: sudo find / -name "apt“
Getting a detailed list of files/directories: sudo find / -name "apt" -ls
Listing directories only: find / -type d -name "apt" -ls
Performing a case insensitive search: find / -type d -iname "apt“
Finding a specified directory: find / -type d -name "project.images"
Finding with wildcards: find . -name pupp*
find / -maxdepth 2 -name passwd: Find file under root and one level down
find / -mindepth 3 -maxdepth 5 -name passwd: Find file between sub-directory level 2 and 4
22. Finding Files - Find (contd…)
Find file based on file permissions irrespective of other permissions
find . -perm -g=r -type f -exec ls -l {} ; : Find files which have read permission to group
find . -perm 040 -type f -exec ls -l {} ; : Find files which have read permission only to group [ search by octal ]
find . -perm g=r -type f -exec ls -l {} ; : Find files which have read permission only to group
Find empty files
find ~ -empty : find all empty files in home directory
find . -maxdepth 1 –empty : List all the empty files only in home directory
find . -maxdepth 1 -empty -not -name “.*“ : List only the non-hidden empty files only in the current directory
Find Files Based on file-type
find . -type d : Find all directories
find . -type f : Find normal files only
find . -type f -name ‘.*’ : Find hidden files
find -type d -name ‘.*’ : Find hidden directories
Find Files by Size : - means less than the give size, + means more than the given size, and no
symbol means exact given size
find ~ -size +100M
find ~ -size -100M
find ~ -size 100M
23. Finding Files - whereis, which, whatis
whereis : command to locate the binary, source, and manual page files for a
command
Usage: whereis [-options]
whereis -b whereis : Locate binaries for a command
whereis -m whereis : Locate man pages for a command
whereis -B /bin -f chmod : Locate binaries in a specified path
whereis -M /usr/share/man/man1 -f open : Locate man pages with limited scope
which : simple command to locate executables in the system.
It allows user to pass several command names as arguments to get their paths in the system,
searches the path of executable in system paths set in $PATH environment variable
Usage: which [-option]
which ls open chmod grep
which -a echo : display all paths
Whatis : displays brief information for command that matches the argument
passed to it
whatis [-options] : whatis ls, whatis cat, whatis cd etc.
24. I/O Redirection >, <, >>, <<
Redirecting the source of an input to a command and the destination of the
output it produces to be the files
Input and output in the Linux environment is distributed across three streams:
stdin : Standard Input - input to a program - input stream typically carries data from a user to a program
usually through keyboard
stdout : Standard Output - output from a program – output stream writes data that is generated by a
program. When the standard output stream is not redirected, it will output text to the terminal
stderr : Standard Error - error output from a program - writes the errors generated by a program that has
failed at some point in its execution. Default destination for this stream is the terminal display
Stream Redirection: these commands write standard output to a file
Overwrite : Commands with a single bracket overwrite the destination's existing contents
> - standard output
< - standard input
2> - standard error
Append : Commands with a double bracket append to the destination's existing contents
>> - standard output
<< - standard input
2>> - standard error
25. I/O Redirection (contd…)
File Descriptors
standard streams have their default file descriptors
0 - stdin (Standard Input)
1 - stdout (Standard Output)
2 - stderr (Standard Error)
Examples:
ls -lah . > lsoutput.txt
file >> lsoutput.txt
ls -la /nothing 2> error.txt : redirect stderr
ls -lah . /nothing &> all_output_v2.txt : to redirect both 1 and 2
ls -lah . /nothing &>> all_output_v2.txt : Appending both stdout (1) and stderr (2)
uniq < fruits.txt > uniq_fruits.txt : combining redirects
uniq < fruits.txt | sort -r > rev_sort.txt
sort < fruits.txt
26. Pipes - Joining programs together |
With pipes, standard output of one command is fed into the standard input of another
ls | less : This takes the output of ls and pipes it to the less program. Less displays the data sent to
it one line at a time.
Filters:
One class of programs which can be used with pipes is called “Filters”.
Filters take standard input, perform an operation upon it and send the results to standard output
Some of the main CLI "filters“
cat : concatenate files and print on STDOUT
less : displays data one line at a time
head : output the first part of files
tail : output the last part of files
tee : read from STDIN and write to STDOUT and files
wc : print the number of bytes, words, and lines in files
grep : print lines matching a pattern
sort : sort lines of text files
uniq : remove duplicate lines from a sorted file
cut : remove sections from each line of files
tr : translates characters. Can be used to perform tasks such as upper/lowercase conversions or changing line
termination characters from one type to another
27. Using Common Text Manipulation Tools
tail : output last few lines of a file
tail -n2 grocery.list : -n : represents number of lines
tail -c12 grocery.list : -c : represents number of characters
head : output first few lines of a file
head -n2 grocery.list : -n : represents number of lines
head -c12 grocery.list : -c : represents number of characters
More Usage:
to watch log files
to track output of running processes to see if there are issues
to note when a process finishes - The -f (tail –f) option output appended data even after the end-of-file
marker is reached, and continue displaying output when the stream grows
tee : reads from standard input, and writes to standard output and to files -
duplicates its input, routing it to multiple outputs at once
ls | tee file1.txt file2.txt file3.txt
ls | tee -a file.txt : append to the file
tee command is used to store the output of a command to a file and redirect the same
output as an input to another command
ls ~/ | tee pipe1.txt | grep ^s | tee pipe2.txt | sort -r
28. Using Common Text Manipulation Tools(contd….)
tr : The tr command is used to translate characters from stdin, displaying them on stdout. In its
general form, tr takes two sets of characters, and replaces characters from the first set with
characters from the second set
tr pre-defined character classes:
alnum - alphanumeric characters
alpha - alphabetic characters
blank - whitespace characters
cntrl - control characters
digit - numeric characters
graph - graphic characters
lower - lower-case alphabetic characters
print - printable characters
punct - punctuation characters
space - space characters
upper - upper-case characters
xdigit - hexadecimal characters
Examples:
echo "Who is the standard text editor?" |tr [:lower:] [:upper:] - Upper-case a string
echo 'ed, of course!' |tr -d aeiou - delete characters from a string
echo 'The ed utility is the standard text editor.' |tr -s astu ' ‘ - translate characters to a space
echo 'extra spaces – 5’ | tr -s [:blank:] - -s option flag is used to suppresses extra white space in a sting
29. Working with grep, egrep
grep : print lines matching a pattern
grep "literal_string" filename : search for the given string in a single file
grep "string" FILE_PATTERN : search for the given string in multiple files
grep -i "string" FILE : case insensitive search
grep -r “paul" * : searching in all files recursively
grep -v "go" filename : invert match
grep -c "pattern" filename : counting number of matches
grep -n "go" filename : show line number while displaying the output
grep -l this *.txt : display only file names which match the given pattern
egrep: search for a pattern using extended regular expressions
egrep "support|help|windows" myfile.txt
egrep -c '^begin|end$' myfile.txt