Skip to the content.

Terminal Usage

Command Description
- File
/etc Setting files of all programs in the system is in this file
cat *.php/wc Word counts
cat /etc/passwd Lists all the users
cat /etc/hosts Lists the hosting names and their IP numbers
cd .. Goes to the parent file
cd - Enables us to go to the previous file directory
cd ~ “cd /home/osman” has the same logic
cd /home/osman It is actually “root”/”where the users are”/”user”
cd /var/www/html Enables us to create user,group and to add/delete member
chown -R g-w /resimler Makes the group unable to write
chown -R $USER:AILE /resimler Makes “resimler” folder a part of a group called “AILE”
code . Opens up the files in the VSCode
cp -r "filename" "target folder name" Copies the file as recursive (-r) to the “target folder name”
[Ctrl] + [C] Stops the working command if you have
[Ctrl] + [D] Log out terminal (Saves history)
[Ctrl] + [L] Clears the terminal screen without closing
[Ctrl] + [R] Reverse-i-search
d Directory
du -s -h "folder name" Enables us to see the disk usage of any file as summary (-s) and like human (-h)
fallocate -l 1G test.img Creating a 1GB random file being called as “test.img”
find "folder name" Enables us to figure out the content of any file
git clone SSH Key Clones the repository for given SSH Key
history+pipe+grep+"reference word" Making a search on the history with some reference words
l Link
less test.img Enables us to navigate in the file (shows file content). To quit, use q
ll List long
ln -s /var/www/html Adds a shortcut
lsblk System specifications
lsusb Shows the usb devices
man "commandname" Shows the manual for any command
mkdir /resimler Creates a new folder calles as “resimler” in a predetermined place
nautilus File manager, designed for the GNOME 3 desktop.
update Lists recent versions of the programs in the repository
upgrade Updates our programs being in the “update list”
ping "yarinlar.com" It is used in TERMINAL. If terminal gives us some logical answers, it means that the website, which is in this case “yarinlar.com”, is working
pv It is like cat command but it has a feature of showing the process level of the current task.
pwd Where I am
rm ?.php Deletes the .php files which have only one character in the name
rsync -ravz --delete /source/path/ /target/path/ Deletes the files which are not currently available in the source but available in the target
rsync -ravz /source/path/ /target/path/ Synchronizes the files like scp but it just takes the files which are not currently being in the target. And to make the process fast, -ravz command is used which has the components of
  <table> <thead> <tr> <th>Command</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>rsync r</td> <td>recursive</td> </tr> <tr> <td>rsync a</td> <td>archive</td> </tr> <tr> <td>rsync v</td> <td>verbose</td> </tr> <tr> <td>rsync z</td> <td>zip</td> </tr> </tbody> </table>
scp -r /source/path/* /target/path/ Coppies the files being in the source to the target file. /* means all of the files
shutdown -h now Close the machine and halt now
shutdown -r now Close the machine and restart now
ssh root@$serverip To connect an ip address
sudo mount /dev/sdb2 /media/"user" Mounts the HDD to the user
sudo umount /media/"user"/"flash memory name"/ Savely removes the flash memory from computer
time "command" Shows the time necessary to process any command
touch test.php Creates an empty file called “test.php”
top -i Display dynamic real-time information about running processes. Option -i lets you to hide the idle process and only show the active ones.
unzip teklif.zip To unzip the “teklif.zip”
uptime Shows the time of continuous work for PC
vim .bashrc Enables us to edit the file which contains the commands working when the computer is started
zip -r teklif.zip teklifhazirla To zip the “teklifhazirla” file as “teklif.zip”

NOTE: The files which start with “.” are secret files.

In Detail

for i in *.sql; do echo "Importing: $i"; mysql -u root -proot ozlem2 < $i; done;
# if the content of '~/.my.cnf' is set as
# [client]
# user=root
# password="root"
for i in *.sql; do echo "Importing: $i"; mysql ozlem2 < $i; done;
echo willBeShown
 echo willNotBeShown
echo willBeShown
history
for file in *.jpg; do
    # Extract the base file name without extension
    filename=$(basename -- "$file" .jpg)
    # Convert the base file name to lowercase and replace underscores with dots
    newname=$(echo "$filename" | tr '[:upper:]' '[:lower:]' | sed 's/_/./g').jpg
    # Rename the file
    mv "$file" "$newname"
done