3 Linux Command Line Tutorial (1) (2)
3 Linux Command Line Tutorial (1) (2)
Forensics
Overview
• Introduction to OS and file Systems
• Virtual file system
• File structure
• Path and path variable
• Linux commands
OS and File Systems
Common features of OS
• Process management
• Memory management
• File system
• Device drivers
• Networking
• Security
• I/O
https://en.wikipedia.org/wiki/Operating_system
File Systems
• A file
• is a collection of correlated
information
• information is recorded on secondary
or non-volatile storage like magnetic
disks, optical disks, and tapes.
• A file system
• defines how files are named, stored,
and retrieved from a storage device.
http://home.easy-key.info/images/stories/file_structure.gif
File systems used by operating
systems
• By Unix and Unix-like operating systems
• Linux: XFS, JFS, and btrfs. extended file system
• Solaris
• macOS:
• Hierarchical File System (HFS) + : No support for
dates beyond February 6, 2040
• By Microsoft Windows
• FAT: File Allocation Table
• NTFS: New Technology File System
Manage files vs. manage storage
boxes
Assumption: One person
rents one or multiple boxes.
Name Boxes ID
Frank 1,2,3
… …
Storage File Storage
Unit Box Sector
Usage Person rents boxes File uses sectors
Manage Rental File management
ment management system, (e.g., FAT)
system system
Virtual file system (VFS)
Without an interpreter
https://developer.ibm.com/technologies/linux/tutorials/l-virtual-filesystem-switch/
Linux for digital forensics- Good and
Bad
• Pro
• widely support for many file systems (Virtual file system)
• advanced and powerful tools available
• free and open-source
• compile source code
• flexibility
• Con
• learning curve, e.g., no graphic interface
• trustworthiness of open-source tools
Open a Linux Terminator
same as cmd
• -i, --inode print the
index number of each
file
• -a, --all do not ignore
entries starting with .
dir
What is inode?
• inode is an ID of a file/folder
• unique number
• inode is a data structure of a file
• You store your information in a file,
and the operating system stores the permission information
information/metadata about a file in
an inode
• inode points to the content of a file
• How to access to a file?
• inode ID block pointers
• file name=>inode ID
https://www.slashroot.in/inode-and-its-structure-linux
Disk free information (df) inode
https://www.linux.com/sites/lcom/files/styles/rendered_file/public/standard-unix-filesystem-hierarchy.png?itok=CVqmyk6P
Show Linux file system from root /
Check where you are (impact all the commands you entered)
Clear screen
cd, cls
Show details of a file/directory
Show Linux file system from root
with tree
Remember use following
command for help
tree --help
Show current working directory
(pwd) with tree
Linux commands are files!
Display ls command under /bin
Why can ls be executed in any folder? => Need to understand path (see next slide)
Path and Path variable
What is path in a file system?
• A path is a hierarchical representation of the location (address) of a
file or directory within the file system's directory structure.
• A path describes the route or sequence of directories (folders) you
must navigate through to reach a specific file or directory.
• Paths are used to uniquely identify and access files and directories on
a computer or storage device.
Example of paths
cd .. 32
Path variable ($PATH)
path
Adding a new path (export)
36
Create folders (mkdir)
home
\myfolder
\mysubfolder
mkdir
Delete folders (rmdir)
rmdir
Create a new text file (echo)
\user home
\myfolder
Show the content of the file
hello
my_first_file.txt
world
Create a file (leafpad)
or nano command
40
File Copy & Deletion
41
Copy a file (cp)
copy
Copy a file to a different location
43
Remove a file (rm)
44
Rename a file (mv)
45
move/ copy and ren
Search for information
Search for a string in a text file
(grep)
grep search
50
Test network connection using IP
51
List all open TCP ports
-l, --listening display listening server sockets
-n, --numeric port number (don't resolve names)
-t, --tcp
nmap localhost -p 21
Download a file (wget)
https://pbs.twimg.com/media/DulILzQXcAAkFMV.jpg
Create a script file
Create a simple script file
Create a script using leafpad shebang: indicate the interpreter
that should be used to execute the
script or program that follows
#!/bin/sh
.bat
Linux Permissions
57
Execute a script file in a different
folder
Add a path to the path variable
Update/Install software
Update software
Install terminator
63
Zip/unzip files