Linux is most popular O.S among servers. Here are some basic commands that every Linux users should know.
There are “\” and “/” those are important to understand. “\” is used to escape characters while “/” is directory separator.
“.” is used to represent current directory. if used in start of a file name it hides that file.
“..” – parent directory.
“~” – User’s home directory.
“*” is used to represent one or more characters in a file name. file*.txt can be file2003.txt or file6.txt
“?” represent a single character in a file name. hello?.php can be helloz.php or hello1.php
“[ ]” represent a range of values.
“|” represent pipe. It redirects output of one command to other command – ls | more
“>” redirects output of a command to a new file. If file already exists then it overwrites the file.
“>>” redirects output of a command to the end of an existing file. like
“<" redirect a file as input to a program.
";" command separator. this operator separates multiple commands on a single line, can be executed on a single line.
"&&" is a command separator but it executes second command if first command finished without errors.
"&" executes a command in back end.
Linux File system.
Linux has a tree-structure like folders and files hierarchy. "/" is the root or base level directory. All other directories are child directories of this directory.
Other directories.
"/bin" - binary programs are stored in this directory.
"/boot" - boot loader files
"/etc" - host related files
"/dev" - device or hardware related files
"/lib" - kernel modules, shared libraries
"/home" - user's personal home files and directories.
"/proc" - process related information
"/root" - root is the admin or super user in a Linux operating system, this directory is home directory of root user.
"/tmp" - temporary files
"/sbin" - system binaries
"/usr" - shareable data
"/usr/bin" - user's programs are kept here
"/usr/include" - header files of c complied files
"/usr/local" - locally installed files are stored in this directory
"/usr/sbin" - none-vital system files
"/usr/share" - independent data of Linux architecture
"/usr/src" - Linux kernel and source programs
"/var" - variable data such as logs
ls - command is used to list directory contents.
Help for a command.
We can see help for a particular command by typing -h or --help command.
Example:
man command
Manual pages are used to find more help about a command.
Example: ls man
mkdir - makes a new directory
rmdir - removes a directory
cat /proc/cpuinfo - displays information about the CPU.
Tab is used to autocomplete a command.
This was an introduction to Linux and basic commands in next chapters we will explore more advanced topics
There are “\” and “/” those are important to understand. “\” is used to escape characters while “/” is directory separator.
/usr/src/linux“.” is used to represent current directory. if used in start of a file name it hides that file.
“..” – parent directory.
“~” – User’s home directory.
“*” is used to represent one or more characters in a file name. file*.txt can be file2003.txt or file6.txt
“?” represent a single character in a file name. hello?.php can be helloz.php or hello1.php
“[ ]” represent a range of values.
“|” represent pipe. It redirects output of one command to other command – ls | more
“>” redirects output of a command to a new file. If file already exists then it overwrites the file.
like ls | output.txt“>>” redirects output of a command to the end of an existing file. like
echo "hello" > file.txt“<" redirect a file as input to a program.
";" command separator. this operator separates multiple commands on a single line, can be executed on a single line.
"&&" is a command separator but it executes second command if first command finished without errors.
"&" executes a command in back end.
Linux File system.
Linux has a tree-structure like folders and files hierarchy. "/" is the root or base level directory. All other directories are child directories of this directory.
Other directories.
"/bin" - binary programs are stored in this directory.
"/boot" - boot loader files
"/etc" - host related files
"/dev" - device or hardware related files
"/lib" - kernel modules, shared libraries
"/home" - user's personal home files and directories.
"/proc" - process related information
"/root" - root is the admin or super user in a Linux operating system, this directory is home directory of root user.
"/tmp" - temporary files
"/sbin" - system binaries
"/usr" - shareable data
"/usr/bin" - user's programs are kept here
"/usr/include" - header files of c complied files
"/usr/local" - locally installed files are stored in this directory
"/usr/sbin" - none-vital system files
"/usr/share" - independent data of Linux architecture
"/usr/src" - Linux kernel and source programs
"/var" - variable data such as logs
lsls - command is used to list directory contents.
ls -a or ls --all - this command is used to display all hidden contents of a directory or files starting with .Help for a command.
We can see help for a particular command by typing -h or --help command.
Example:
ls -h or grep --helpman command
Manual pages are used to find more help about a command.
Example: ls man
cd - Change directory - This command is used to change current directory.cd /var/www/htmlpwd - print working directoryfile - tells about type of file file /bin/ls will output file type as execute able. cat - displays contents of a file.head - displays few top lines of a filetail - displays few last lines of a filecp - copies a file from one location to other cp file1.html /var/www/html/file1.htmlmv - moves a file from one location to other location mv file1.html /var/www/html/file1.htmlrm - removes a files rm /var/www/html/first.htmlmkdir - makes a new directory
rmdir - removes a directory
which - displays location of a command.locate - search a file like locate mozillaps - list all currently running processesw - list all logged users and what activity they are doingid - prints user id and group iddu - displays disk usagedf - displays disk file system usagetop - displays all the processes running in system in real timefree - displays amount of free and used memory in the system.cat /proc/cpuinfo - displays information about the CPU.
cat /proc/meminfo - display lots of information about current memory usageuname -a - prints system information to the screenclear - clears the screenmore - display a file, or program output one page at a timeless - display a file, or program output one page at a time, can be scrolled backwardsgrep - Search for a pattern in a file or program output.lpr - print a file or program output. Esort - sort a file or program output.su - allows to switch other user's account such as switch to root user account.history - shows history of a commandTab is used to autocomplete a command.
This was an introduction to Linux and basic commands in next chapters we will explore more advanced topics
No comments:
Post a Comment