Basic Linux commands for Devs Flashcards
man {command}
use to get more details about the specified command and arguments that can be used with it
pwd
“Present working directory”. prints the path to the current directory
open {filename/url}
used to open the specified file or internet URL
ls
list all files and folders in the current directory
-a : adds hidden elements
-l : long format (adds more information)
-al : does both
mkdir {name}
used to create a new folder/directory
can also make multiple at once by adding space separated names ex.
mkdir folder1 folder2 folder3
-p: create nested folders
ex:
mkdir -p foler1/nested
touch {name}
used to create new files.
ex:
touch file.txt
touch file.txt file2.py
rmdir
used to remove empty folders
ex:
rmdir folder
rm
used to remove empty or non-empty folders/directories/files
ex:
rm file.txt
rm -d empty_folder
rm -r non_empty_folder
rm -r * (removes all files/folders in current directory)
note:
files will not be moved to recycle bin, it is a permanent deletion.
cp {file} {folder}
used to copy files into the target folder
ex:
cp file1.txt folder
mv {file} {folder}
used to move files into the target folder
ex:
mv file1.txt folder
history
used to show all commands that have been typed into the Linux shell.
diff {file1} {files2}
used to show the difference between two files
head {filename}
used to show the first {10 lines default} of the file
ex:
head -n 15 logfile.txt
{will show the first 15 lines of logfile.txt}
tail {filename}
used to show the last{10 lines default} of the file
ex:
tail -n 15 logfile.txt
{will show the last 15 lines of logfile.txt}
echo {msg/$variable}
used to print things to the terminal.
ex:
echo $username
{prints value of username}
echo *.txt
{prints all txt files in the dir to terminal}