Basic Linux commands for devs (flipped) Flashcards
use to get more details about the specified command and arguments that can be used with it
man {command}
“Present working directory”. prints the path to the current directory
pwd
used to open the specified file or internet URL
open {filename/url}
list all files and folders in the current directory
ls
-a : adds hidden elements
-l : long format (adds more information)
-al : does both
used to create a new folder/directory
mkdir {name}
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
used to create new files.
touch {name}
ex:
touch file.txt
touch file.txt file2.py
used to remove empty folders
rmdir
ex:
rmdir folder
used to remove empty or non-empty folders/directories/files
rm
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.
used to copy files into the target folder
cp {file} {folder}
ex:
cp file1.txt folder
used to move files into the target folder
mv {file} {folder}
ex:
mv file1.txt folder
used to show all commands that have been typed into the Linux shell.
history
used to show the difference between two files
diff {file1} {files2}
used to show the first {10 lines default} of a file
head {filename}
ex:
head -n 15 logfile.txt
{will show the first 15 lines of logfile.txt}
used to show the last{10 lines default} of a file
tail {filename}
ex:
tail -n 15 logfile.txt
{will show the last 15 lines of logfile.txt}
used to print messages/variable values to the terminal.
echo {msg/$variable}
ex:
echo $username
{prints value of username}
echo *.txt
{prints all txt files in the dir to terminal}