28 May, 2018

Useful commands that we need to write daily

- To rename file or directory 
 * keyword mv old-file/folder new-file/folder

- To delete file or directory
 * keyword rm old-file/folder new-file/folder

========= For nano editer block ===================
- To leave from nano editor
* keyword ctr + x

- To cut text in nano editor
 * keyword ctr + k

- To copy in nano editor
 * keyword ctr + c

- To past in nano editor
 * keyword ctr + u

- To Search in nano editor
 * keyword ctr + w

========= End for nano editer block ==================


========= For vi or vim editer block =================

- To select text in vim or vi editor
 * keyword v

- To Copy in vim or vi editor
 * keyword y

- To Cut in vim or vi editor
 * keyword d

- To Paste in vim or vi editor
 * keyword p or P

- To leave from vim or vi
 * keyword esc and then :wq! ( quit and write)

========= End for vi or vim editer block ===============

*Gedit it will prompt (very easy)

========= For changing directory block =================

-Changing Directories

* cd changes directories

-To an absolute or relative path:
* cd /home/joshua/work
* cd project/docs

-To a directory one level up:
* cd ..

-To your home directory:
* cd

-To your previous working directory:
* cd -- 

========= End for changing directory block =================


========= For list file or directory block =================

+Lists the contents of the current directory or a specified directory

- ls [options] [files_or_dirs]

- ls -a (include hidden files)

- ls -l (display extra information)

- ls -R (recurse through directories)

- ls -ld (directory and symlink informa

========= End for list file and directory block =================

========= For copy file or directory block =================

+Copying Files and Directories

- cp is to copy files and directories (syntax)

- cp [options] file destinatio (one file)

- cp [options] file1 file2 destination ( more than one files)

*Ex. cp huor/file3 huor/file4 test_copy/

*Note : If the destination is a directory, the copy is placed there

If the destination is a file, the copy overwrites the destination

If the destination does not exist, the copy is renamed

========= End for copy file and directory block =================

========= For Move file and directory block =================

+Moving and Renaming Files and Directories

- mv is to move and/or rename files and (Syntax)

- mv [options] file destinatio (one file)

- mv [options] file1 file2 destinati (more than one file)

- Destination works like cp

========= End for copy file and directory block =================

========= For creating and removing file block =================

+Creating and Removing Files

- keyword touch is to create empty files

- keyword rm is to remove files

- keyword rm -i file (interactive)

- keyword rm -r directory (recursive)

- keyword rm -f file (force)

========= End for creating and removing file block =================

========= For Creating and Removing Directories block =================

+Creating and Removing Directories

- mkdir creates directories

- rmdir removes empty directories

- rm -r recursively removes directory trees

========= End for Creating and Removing Directories block =================


========= For Changing File Ownership block =================

+Changing File Ownership

 *Note : Only root can change a file's owner

 *Note : Only root or the owner can change a file's group

- Ownership is changed with chown:

- chown [-R] user_name file|directory

+Group-Ownership is changed with chgrp:

 chgrp [-R] group_name file|direct

========= End for Changing File Ownership block =================


========= for Changing Permissions - Symbolic Method block =================

+To change access modes:

- chmod [-R] mode file

* Where mode is:

*Note : u,g or o for user, group and other

*Note : + or - for grant or deny

*Note : r, w or x for read, write and execute

Examples:
ugo+r: Grant read access to all

o-wx: Deny write and execute to o

========= End for Changing Permissions - Symbolic Method block =================


========= for Changing Permissions - Numeric Method block =================
+ Changing Permissions - Numeric Method

*Note : Uses a three-digit mode number

*Note : first digit specifies owner's permissions

*Note : second digit specifies group permissions

*Note : third digit represents others' permissions

Permissions are calculated by adding:

4 (for read)

2 (for write)

1 (for execute)

========= End for Changing Permissions - Numeric Method block =================

No comments:

Post a Comment