what do moshiur@pc:~$ means ?
- moshiur: The username of the current user
- pc: The hostname of the server
- ~: The current directory. In bash, which is the default shell, the ~, or tilde, is a special character that expands to the path of the current user’s home directory; in this case, it represents /home/sammy
- $: The prompt symbol. This denotes the end of the command prompt, after which the user’s keyboard input will appear
root@webapp:/var/www# Logged in as a root in var/www directory
sudo bash
less /etc/passwd
OR
getent passwd
getent passwd {1000..60000}
pwd
cd /var/www/html (Using Absoulate path)
cd var (Using relative path)
If you run the cd command without any arguments, you will be returned to your current user’s home directory.
cd ~ OR cd
cd /var/www/html
cd -
cd /
cd ~moshiur
cd 'Dir name with space'
cd Dir\ name\ with\ space
The ls command will print a listing of the current directory’s files and directories.
ls
A Linux command has the following basic syntax:
ls [ Options ] [File]
- ls -a list all files including hidden file starting with '.'.
- ls -d list directories - with ' */'.
- ls -l list with long format - show permissions.
- ls -F Append indicator (one of */=>@|) to entries.
- ls -lh This command will show you the file sizes in human readable format.
- ls -r list in reverse order.
- ls -i list file's inode(index) number.
- ls -ltr View Reverse Output Order by Date.
- ls -t sort by time & date.
- ls -n It is used to print group ID and owner ID instead of their names.
- ls -m A list of entries separated by commas should fill the width.
- ls -g This allows you to exclude the owner and group information columns.
- ls -q Force printing of non-graphic characters in file names as the character `?';.
- ls -Q Place double quotations around the entry names.
- ls --help Detailed command here
- ls -la /home you could check the contents of /home, regardless of your current directory.
less /etc/services
less is an application that will continue to run and occupy the screen until you exit.
scroll via ENTER OR UP DOWN arrow of keyboard.
Use /yourSeasrchQuery to search something . Press n for forward and N for see backword search result.
Use q for exit.
touch file1
touch /home/sammy/file2 /home/sammy/file3 //create multiple file at same time even can use absoulate path
mkdir test/example // Test directory must exists
mkdir -p some/other/directories
you can use the -p option.This allows you to create nested directories in one step.The command will make the some directory first, then it will create the other directory inside of that. Finally it will create the directories directory within those two directories.
mv file1 test
Note: As with the mv command, it is possible to overwrite a file if you are not careful about the filename you are using as the target of the operation.
cp file3 file4
cp -r some again // for directory
rm file1
rmdir some // For empty directory
rm -r some // for delete everything in some including some DIR
env
echo $PATH
cd $HOME
VAR=value