Basic Linux commands
In this article i wanted to cover the basic commands that i use almost everyday on linux EC2 instances. This is a basic jot down of commands i use, it may not be professional in formatting and all i am just starting to blog and trying to make it an habit, so if you are reading this please ignore the formatting.
vim
Usage : vim fileName -- this is basically used to edit plain txt files.
example: vim testdata.json
ls
Usage: ls -- this is used to list the content of a directory
example: go to the directory you want to list the contents and then ls.
cd
Usage: cd directoryName -- This is used to change directories
example: cd directoryYouWantToGoTo
mkdir
Usage: mkdir directoryName -- this is used to create a directory
example: mkdir directoryName
cp
Usage : cp sourceFile destinationFile -- this is used to copy contents of one file to another file. this can even be used to copy contents of directory using option available with cp command.
example: cp pathToSourceFile pathToDestinationFile
rm
Usage: rm fileName -- this is used to delete or remove a file.his can even be used to delete contents of directory using option available with rm command
example: rm fileName
find
Usage: The find utility recursively descends the directory tree for each path listed, evaluating an expression (composed of the primaries'' and
operands'' listed below) in terms of each file in the tree.
example: find / ! -name "*.c" -print -- Print out a list of all the files whose names do not end in .c.
history
Usage: history -- this will list the commands that you have used before history.
grep
Usage: grep is used for simple patterns and basic regular expression.
example: grep 'patricia' myfileName --- o find all occurrences of the word `patricia' in a file
tail
Usage: tail -- display the last part of a file
example: tail fileName
cat
Usage: cat -- concatenate and print files
example: cat fileName --- this will printout the contents of file to the standard output
chmod
Usage: chmod -- change file modes or Access Control Lists, this has a lot of options with.
curl
Usage: curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction.
df
Usage: df -- display free disk space
The df utility displays statistics about the amount of free disk space on the
specified filesystem or on the filesystem of which file is a part
du
Usage: du -- display disk usage statistics
The du utility displays the file system block usage for each file argument and for each directory in the file hierarchy rooted in each directory argument
man
Usage: I left this for the last because it is the most useful command to know more about all other command and the options these commands will offer. it is highly impossible to remember all these commands and the options they offer so just go to the terminal and hit man followed by the command you are interested in
example: man chmod --- this will give you the description of why chmod can be used and all the options it will offer and some times it will also give you some example of things you can do with the command. This is a very helpful command. I even used some the description for some commands from what man command gives for that respective command and used in this article.