LinuxCommandLibrary

Files & Folders

Create file

$ touch [fileName]
copy
$ echo $null >> [fileName]
copy

Delete file

$ rm [fileName]
copy

Display file content

$ cat [fileName]
copy

Edit text file

$ vi [fileName]
copy
$ nano [fileName]
copy
$ emacs [fileName]
copy
$ pico [fileName]
copy
$ ed [fileName]
copy

Copy file or folder

$ cp [fileName] [newFileName]
copy
$ cat [fileName] > [newFileName]
copy
$ dd if=[fileName] of=[newFileName]
copy

Move/Rename file or folder

$ mv [fileName] [newFileName]
copy

Create folder

$ mkdir [folderName]
copy

Delete folder

$ rm -r [folderName]
copy

Change folder

$ cd [path]
copy

Create a physical link to file or folder

$ ln [fileOrigin] [linkDest]
copy

Find phrase within file

$ grep [phrase] [fileName]
copy

Get filesystem of partition

$ file -sL [partition]
copy

Mount filesystem

$ mount /dev/[device] [path]
copy

Make file executable

$ chmod +x [file]
copy

Show size of all sub directories

$ du -h --max-depth=1
copy

Display and update information of files

$ watch -d -n 2 'df; ls -FlAt;'
copy

List trash files

$ ls -l ~/.local/share/Trash/files
copy

Empty trash

$ rm -r ~/.local/share/Trash
copy
$ gio trash --empty
copy
$ gvfs-trash --empty
copy

Move file to trash

$ gio trash [file]
copy

View file permission

$ ls -l [file]
copy

Set file permission

$ chmod [permission] [file]
copy

Change owner of file

$ chown [user] [file]
copy
Copied to clipboard