Difference between revisions of "Useful Linux commands"
Line 1: | Line 1: | ||
This page will contain some useful Linux commands. | This page will contain some useful Linux commands. | ||
− | + | Vocabulary – in the UNIX/Linux world directory is a special type of file that contains a list of objects (files or other directories). Folder and directory are interchangeable terms. | |
+ | Directories are organized in a tree structure. The highest in the chain in ‘/’ (root directory). | ||
+ | |||
+ | ls - (list) – list the contents (files and directories) of a directory. If no directory path is specified it defaults to your working directory. | ||
+ | Some useful arguments: | ||
+ | * ls -l displays the permissions, user and group ownership, and date of creation in addition to displaying the contents. | ||
+ | * ls doesn’t display hidden files by default (.<filename> - if a filename starts with dot, then it is not visible). ls -a shows you hidden files too. | ||
+ | |||
+ | mkdir - (make directory) – creates a new directory. | ||
+ | |||
+ | cd - (change directory) – change your working directory to a specified path. If no path is provided, then it brings you to the previous working directory. | ||
+ | * Useful shortcuts – cd .. (“cd out”) – brings you to the parent directory of your current working directory. | ||
+ | * cd ~ - your home directory | ||
+ | * cd / - here the path is / so it brings you to the root directory. | ||
+ | |||
+ | pwd – (print working directory) – prints the full path of your current working directory | ||
+ | |||
+ | rm - (remove) – deletes files. If you want to delete a folder use rm -r option. | ||
+ | |||
+ | cp <source_file_path> <target_file_path> (copy)- make a copy of a file. (use -r option for folders) | ||
+ | |||
+ | mv –(move)- move a file to a new location. This command is also often used to rename files. | ||
+ | |||
+ | vi/nano/emacs – file editors – also helps you create new files. | ||
+ | |||
+ | diff –(difference) - you can provide this command with two files and it will compare them line by line. If these files are identical then the output will be empty. | ||
+ | |||
+ | cat – (concatenate) – displays the contents of a file to stdout. | ||
+ | |||
+ | grep – searches text data for lines that contain some string. | ||
+ | |||
+ | head – display | ||
+ | |||
+ | whoami – displays your username | ||
+ | |||
+ | history – display your command line history | ||
+ | clear – clears your terminal window | ||
+ | |||
+ | chown – change owner of a file/directory | ||
+ | |||
+ | chmod – change permissions of a file/directory | ||
+ | |||
+ | chgrp – change group ownership of a file/directory | ||
+ | |||
+ | passwd – change your password | ||
+ | |||
+ | echo – pring a string to stdout | ||
+ | |||
+ | sudo – run a command with root permissions | ||
+ | |||
+ | su – (substiture user) - change the user | ||
+ | |||
+ | apt/yum – package managers | ||
+ | |||
+ | hostname – display the name of a host (machine you’re working on) | ||
+ | |||
+ | exit – exit the terminal | ||
+ | |||
+ | date – display date/time | ||
+ | |||
+ | |||
+ | |||
+ | mount, df, ps(pstree), awk, sed, head, tail, ln, alias, scp, ssh, wget, find, which, locate, chown, man, tar, ifconfig, ping | ||
+ | |||
Piping('|') | Piping('|') |
Revision as of 20:26, 21 June 2020
This page will contain some useful Linux commands.
Vocabulary – in the UNIX/Linux world directory is a special type of file that contains a list of objects (files or other directories). Folder and directory are interchangeable terms. Directories are organized in a tree structure. The highest in the chain in ‘/’ (root directory).
ls - (list) – list the contents (files and directories) of a directory. If no directory path is specified it defaults to your working directory. Some useful arguments:
- ls -l displays the permissions, user and group ownership, and date of creation in addition to displaying the contents.
- ls doesn’t display hidden files by default (.<filename> - if a filename starts with dot, then it is not visible). ls -a shows you hidden files too.
mkdir - (make directory) – creates a new directory.
cd - (change directory) – change your working directory to a specified path. If no path is provided, then it brings you to the previous working directory.
- Useful shortcuts – cd .. (“cd out”) – brings you to the parent directory of your current working directory.
- cd ~ - your home directory
- cd / - here the path is / so it brings you to the root directory.
pwd – (print working directory) – prints the full path of your current working directory
rm - (remove) – deletes files. If you want to delete a folder use rm -r option.
cp <source_file_path> <target_file_path> (copy)- make a copy of a file. (use -r option for folders)
mv –(move)- move a file to a new location. This command is also often used to rename files.
vi/nano/emacs – file editors – also helps you create new files.
diff –(difference) - you can provide this command with two files and it will compare them line by line. If these files are identical then the output will be empty.
cat – (concatenate) – displays the contents of a file to stdout.
grep – searches text data for lines that contain some string.
head – display
whoami – displays your username
history – display your command line history clear – clears your terminal window
chown – change owner of a file/directory
chmod – change permissions of a file/directory
chgrp – change group ownership of a file/directory
passwd – change your password
echo – pring a string to stdout
sudo – run a command with root permissions
su – (substiture user) - change the user
apt/yum – package managers
hostname – display the name of a host (machine you’re working on)
exit – exit the terminal
date – display date/time
mount, df, ps(pstree), awk, sed, head, tail, ln, alias, scp, ssh, wget, find, which, locate, chown, man, tar, ifconfig, ping
Piping('|')