Linux File Permissions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Linux Basics

Linux File Structure


In the Linux file structure files are grouped according to purpose. Ex:
commands, data files, documentation. Parts of a Unix directory tree are listed
below. All directories are grouped under the root entry "/". That part of the
directory tree is left out of the below diagram. See the FSSTND standard (File
system standard).

root - The home directory for the root user

home - Contains the user's home directories along with directories for services

bin - Commands needed during boot up that might be needed by normal users

sbin - Like bin but commands are not intended for normal users. Commands run
by LINUX.

proc - This file system is not on a disk. It is a virtual file system that exists in
the kernels imagination which is memory.

1 - A directory with info about process number 1. Each process has a directory
below proc.

usr - Contains all commands, libraries, man pages, games and static files for
normal operation.

bin - Almost all user commands. some commands are in /bin or /usr/local/bin.

sbin - System admin commands not needed on the root file system. e.g., most
server programs.

include - Header files for the C programming language. Should be below


/user/lib for consistency.

lib - Unchanging data files for programs and subsystems


local - The place for locally installed software and other files.
man - Manual pages
info - Info documents
doc - Documentation
tmp
X11R6 - The X windows system files. There is a directory similar to usr below
this directory.

X386 - Like X11R6 but for X11 release 5

boot - Files used by the bootstrap loader, LILO. Kernel images are often kept
here.

lib - Shared libraries needed by the programs on the root file system

modules - Loadable kernel modules, especially those needed to boot the system
after disasters.

dev - Device files

Linux File Management and Viewing


File and Directory management

cd : Change the current directory. With no arguments "cd" changes to the users
home directory.

cp :cp <source> <destination> Copy a file from one location to another.

dd :Convert and copy a file formatting according to the options. Disk or data
duplication.

dir : List directory contents.

dircolors Set colors up for ls.

file :Determines file type. Also can tell type of library (a.out or ELF).

find
Ex: find $Home –name readme Print search for readme starting at home and
output full path.

How to find files quickly using the find command:


Ex: find ~ -name report3 –print
"~" = Search starting at the home directory and proceed through all its
subdirectories
"-name report3" = Search for a file named report3
"-print" = Output the full path to that file
install Copy multiple files and set attributes.
ln Make links between files.
locate File locating program that uses the slocate database.

losetup Loopback device setup.

Ls: List files. Option -a, lists all, see man page "man ls"
Ex: "ls Docum Projects/Linux" - The contents of the directories Docum
and Projects/Linux are listed.
To list the contents of every subdirectory using the ls command:
1. Change to your home directory.
2. Type: ls -R

mkdir : Make a directory.

mv: Move or rename a file. Syntax: mv <source> <destination> Ex: mv


filename directoryname/newfilename

pathchk: Check whether filenames are valid or portable.

pwd : Print or list the working directory with full path (present working
directory).

rm : Ex: "rm .*" - Effect: Delete system files (Remove files) –i is interactive
option.

rmdir : rmdir <directory> - Remove a directory. The directory must be empty.

slocate
Provides a secure way to index files and search for them. It builds a database of
files on the system.

stat(1u) Used to print out inode information on a file.

Sum: Checksum and count the blocks in a file.

test :Check file types and compare values.

vdir List directory contents.

File viewing and editing


ed : Editor

emacs: Full screen editor.

gitview: A hexadecimal or ASC file viewer.


head head linuxdoc.txt - Look at the first 10 lines of linuxdoc.txt.

less q-mandatory to exit, Used to view files.

more b-back q-quit h-help, Used to view files.

pico Simple text editor.

tail tail linuxdoc.txt - Look at the last 10 lines of linuxdoc.txt.

vi Editor with a command mode and text mode. Starts in command mode.

VI Editor
List of Commands for vi - An Unix/Linux
Editor
Complete Documentation
The vi editor is a common editor for unix systems in that it makes use of a regular keyboard
with an escape key. On the DECstation, the escape key is the F11 key. It therefore works on
all unix computers. Complete documentation is available by typing
man vi

at the unix prompt.

Starting an Editing Session


vi filename

where filename is the name of the file to be edited.

Undo Command
u
undo the last command.

Screen Commands
CTL/l
Reprints current screen.
CTL/L
Exposes one more line at top of screen.
CTL/E
Exposes one more line at bottom of screen.
CTL/F
Pages forward one screen.
CTL/B
Pages back one screen.
CTL/D
Pages down half screen.
CTL/U
Pages up half screen.

Cursor Positioning Commands


j
Moves cursor down one line, same column.
k
Moves cursor up one line, same column.
h
Moves cursor back one character.
l
Moves cursor forward one character.
RET
Moves cursor to beginning of next line.
0
Moves cursor to beginning of current line.
$
Moves cursor to end of current line.
SPACE
Moves cursor forward one character.
nG
Moves cursor to beginning of line n. Default is last line of file.
0
Moves the cursor to the first character of the line.
:n
Moves cursor to beginning of line n.
b
Moves the cursor backward to the beginning of the previous word.
e
Moves the cursor backward to the end of the previous word.
w
Moves the cursor forward to the next word.
/pattern
Moves cursor forward to next occurrence of pattern.
?pattern
Moves cursor backward to next occurrence of pattern.
n
Repeats last / or ? pattern search.

Text Insertion Commands


a
Appends text after cursor. Terminated by escape key.
A
Appends text at the end of the line. Terminated the escape key.
i
Inserts text before cursor. Terminated by the escape key.
I
Inserts text at the beginning of the line. Terminated by the escape key.
o
Opens new line below the current line for text insertion. Terminated by the escape key.
O
Opens new line above the current line for text insertion. Terminated by the escape key.
DEL
Overwrites last character during text insertion.
ESC
Stops text insertion. The escape key on the DECstations is the F11 key.

Text Deletion Commands


x
Deletes current character.
dd
Deletes current line.
dw
Deletes the current word.
d)
Deletes the rest of the current sentence.
D, d$
Deletes from cursor to end of line.
P
Puts back text from the previous delete.

Changing Commands
cw
Changes characters of current word until stopped with escape key.
c$
Changes text up to the end of the line.
C, cc
Changes remaining text on current line until stopped by pressing the escape key.
~
Changes case of current character.
xp
Transposes current and following characters.
J
Joins current line with next line.
s
Deletes the current character and goes into the insertion mode.
rx
Replaces current character with x.
R
Replaces the following characters until terminated with the escape key.

Cut and Paste Commands


yy
Puts the current line in a buffer. Does not delete the line from its current position.
p
Places the line in the buffer after the current position of the cursor.

Appending Files into Current File


:R filename
Inserts the file filename where the cursor was before the ``:'' was typed.

Exiting vi
ZZ
Exits vi and saves changes.
:wq
Writes changes to current file and quits edit session.
:q!
Quits edit session (no changes made).
!q
Force Quit.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy