Here is the compiled list of basic Linux user commands required for working on Linux platform.
Listing of files and folders
do not hide entries starting with .
use a long listing format
reverse order while sorting
print size of each file, in blocks
list entries by lines instead of by columns
Copy files and directories
if an existing destination file cannot be opened, remove it and try again
prompt before overwrite
link files instead of copying
-R, -r, --recursive
copy directories recursively
explain what is being done
stay on this file system
Make a directory if it does not already exist
Remove files and folders. By default, it does not remove folders
ignore nonexistent files, never prompt
prompt before any removal
-r, -R, --recursive
remove the contents of directories recursively
explain what is being done
Removes folders and files in recursively without asking confirmation from user
Show the name of the current working directory
Creates links to a file. Useful for creating alias for long file names
prompt whether to remove destinations
make symbolic links instead of hard links
Moves or renames file.
do not prompt before overwriting
prompt before overwrite equivalent
Change permission for file or directory. There are three types of access:
Each file belongs to a specific user and group. Access to the files is controlled by user, group, and what is called other.
The format is `[ugo][[+-=][rwx]
The operator `+' causes the permissions selected to be added to the existing permissions . `-' causes permissions to be removed; and `=' causes them to be the only permissions that the file has.
The letters `rwx' select the new permissions for the affected users: read (r), write (w), execute (or access for directories) (x).
Concatenate the files and sends the file to standard output
number all output lines
never more than one single blank line
Show the amount of disk space used on each mounted files system.
Print disk usage (as the number of 1 KB blocks used by each named directory and its subdirectories; default is the current directory).
write counts for all files, not just directories
-B, --block-size=SIZE use SIZE-byte blocks
print size in bytes
produce a grand total
Searches for files in the directory hierarchy
Searches for files in the directory hierarchy. Locate command works faster than find command
Searches for regular expression or a pattern in file. By defaults prints the matching lines
$ grep "Hello" file1
This command is a manual for Linux commands. Provides help for any command in Linux. To find the usage and all the options available with that command type man command
Change owner, change the user and/or group ownership of each given file to a new Owner.
Create tape archives and add or extract files. Basically used to compress and decompress files
append files to the end of an archive
list the contents of an archive
only append files that are newer than copy in archive
-x, --extract, --get
extract files from an archive
verbosely list files processed
-w, --interactive, --confirmation
ask for confirmation for every action
-z, --gzip, --ungzip
filter the archive through gzip
|Creating a tar file:
tar -cvf file.tar filetobetarred.txt
It would create a tar named file.tar in the directory you currently are in.
tar -cvf mydir.tar mydir/
In the above example command the system would create a tar file named mydir.tar in the directory you currently are in.
|Extracting the files from a tar file:
tar -xvf testfile.tar
In the above example command the system would uncompress (untar) the testfile.tar file in the current directory.
gzip, gunzip, zcat - compress or expand files
Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz, while keeping the same ownership modes, access and modification times.
Compressed files can be restored to their original form using gzip -d or gunzip
|Find and Replace in vi editor
Search and Replace a word in whole file
Example ": %s/Test/Text/g" - For all lines in a file, find string "Test" and replace with string "Text" for each instance in a file. Run the command in Esc mode in vi editor.