File system Flashcards
Which command should we use to know current directory/ current location?
pwd
Current directory/location can be referenced by…
. in commands
Directory above the current directory can be referenced by…
.. in commands
Absolute path
specifies the path of a file/ directory regardless of the current location
Relative path
specifies the path of a file/ directory which is relative to the current location
display the content of a directory
ls
List All Files including hidden files
Hidden files start with a .
Commonly used for storing user preferences
ls -a
List files in reverse order
ls -r
List files in Recursive list
ls -R
can be used to view a hierarchical structure of the file system
tree
user’s home folder
~ (tilde character)
navigate your way to other directories
cd
create a directory/ multiple directories
mkdir
create subdirectory and parent(s). Required if parent(s) do(es) not pre-exist
mkdir -p dir1/sub2/sub3
remove empty directories
rmdir
remove directories with or without content
rm -r
create files
vi/ vim
touch: creates files, but also has another purpose which is to update time stamp if the file already exists
Display the content of a file
cat
Display a % of the file starting from the beginning
more
Display a screenful of the file starting from the beginning
less
Display the first 10 lines of a file
head
Display the last 10 lines of a file
tail
removes file
rm filename
copy files
cp filename newfilename
counts the number of line, words, and bytes in the files
wc filename
move or rename
Rename: mv originalFilename newFilename
Move a file into directory:
mv filename directoryname
Move multiple files into a directory: mv file1 file2 file3 dir
Provide information abut the content of a file
file filename
ASCII text, directory, empty, shell script text
File - inode
ls -i Inode holds information on files such as: - user and group ownership - file size etc.
In UNIX, each file is uniquely identified by its name and by an index node number called inode.
File - long format
ls -l
Wildcards
- : Match zero or more characters
? : Match one character
[ ] : Match anything in the [ ] for 1 character position
[a-e] : The - is a range separator. This will match a to e.
[!0-9] : ! = negate. This will match anything except 0 to 9.
Every file in UNIX has access permission
Read -r
Write -w
Execute -x
Permissions are defined for three types of users.
User, Group, Other
What does it mean?
drwxr-xr-x
d : file type
“d” means directory
“-“ means regular file
rwx : user permissions
r-x : group permissions
How to change permission?
chmod 751 dir3
4: r - Read
2: w - Write
1: x - execute
0: No permissions