File Operations Flashcards
ls
Lists files and directories in current directory (ls - list).
ls -a
Lists files, dot files and directories in current directory (-a - all.
ls dir1 dir2
Lists files in directory1 and directory2.
ls -l
Lists a long list (-l - long). permissions, number of hard links, owner, group, size, last modified and filename.
What does drwxrwxr-x means?
Position 1: - = file, d = directory, l = symbolic link, p = named pipe, c = character device, b = block device. 2-4: Read, write and execute permissions for the owner. 5-7: Group. 8-10: Other users.
ls -ld dir1
Information about directory but not about what is in the directory.
ls -lh
Prints size in a more readable format.
ls -s
Prepend the size of files.
Sort files by size.
ls -s | sort -n
ls -R
List contents in directories recursively.
cp [options] files (file|directory)
Copy one or several files.
cp -a
Copy directories recursively. Same as cp -r but preserve file attributes.
cp -r
Copy directories recursively. Same as cp -a but does not preserve file attributes.
mv [options] source target
Move. Can also be used to rename a file.
mv file1 file2
Rename file1 to file2.