LinuxCommandLibrary

Files & Folders

Create file

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

Delete file

$ rm [fileName]
copy

Display file content

$ cat [fileName]
copy
$ bat [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
$ rg [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 subdirectories

$ 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
$ stat [file]
copy

Set file permission

$ chmod [permission] [file]
copy

Change owner of file

$ chown [user] [file]
copy

Compare two files

$ diff [file1] [file2]
copy

Create symbolic link

$ ln -s [target] [linkName]
copy

Show file type

$ file [fileName]
copy

Browse file content

$ less [fileName]
copy
$ more [fileName]
copy
$ most [fileName]
copy

Sort file contents

$ sort [fileName]
copy

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community