Skip to content

Instantly share code, notes, and snippets.

@fomychov
Last active March 19, 2024 18:05
Show Gist options
  • Save fomychov/4f6e532e267ac53f2ddce8163170375c to your computer and use it in GitHub Desktop.
Save fomychov/4f6e532e267ac53f2ddce8163170375c to your computer and use it in GitHub Desktop.
linux
#!/bin/bash # any bash-script should start with "shebang"-lint
# after #! indicate path to the bash interpetator
#############################################
# get updates
sudo apt update
apt list --upgradable
sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoremove
apt update && apt full-upgrade -y
-y # all answers are yes
sudo apt-get upgrade python3
#############################################
# find a dir
find / -type d -name 'smth_name'
cd
ls
pwd
cp
mv
cat
less
grep
echo
touch
mkdir
chown
chmod
rm
man + help
clear # clear monitor
cd # change dir
cd .. # one steep back
ls # show content list
ls /home # lisf of chosen dir
ls /home | more # lisf of chosen dir with limitation
ls /home | grep smth # lisf of chosen dir with filter by smth
ls -l # with parameters
ls -la # with parameters, with hidden files
apt update && apt full-upgrade -y
-y # all answers are yes
# start file
firefox filename.pdf
code bash.sh
# copy file
cp -v filename.exe /new/dir
-v # it displays process info
mv -v filename.exe /new/dir # move file
mv -v filename.exe newname.exe # rename file
# install deb package
sudo apt install ./file.deb
# nano - is a text redactor in termonal
nano filename.smth
# cat - show file content
cat filename.text
# grep - filter txt files | show line in file contents smth
cat filename.text | grep smth
-i # ignore case
# show open file and which process uses them
lsof # list open files
lsof | more
-u root # by username root
-u^ root # by except username root
-c nginx # by process nginx
-p 333 # by process ID 333
+D /usr/bin # by the Dir /usr/bin
-i # by network connection
-i :80 # by files port
-i TCP # by protocol
# ----------------------------------------------------#
# tor
apt install tor -y
servise tor status
service tor start
##############
# PowerShell #
##############
winget upgrade -h --all # upgrade all apps
CLS # Очистка экрана.
MD # Создает каталог.
START # Выполняет указанную программу или команду в отдельном окне.
start https://www.youtube.com/
ctrl + end # del all after cursor
ctrl + home # del all before cursor
cd c:\ # go to path
cd -- # на одну папку назад
get-childitem # Gets the files and folders in a file system drive.
Get-ChildItem -Path c:\users\sasha # show list of specific path
Get-ChildItem -Recurse -Include "smth*" # find file with name "smth"
Get-ChildItem -Path c:\users\sasha\downloads -Filter '*.exe'
Get-ChildItem -filter '*.pdf' | sort LastWriteTime -descending | select name
Remove-Item name.pdf
Remove-Item (Get-ChildItem -filter "*.ico")
Get-ChildItem -filter '*.torrent' | Remove-Item -force
Get-ChildItem * -Include *.mp3, *.png
Rename-Item D:\temp\Test\test.txt test_1.txt
Move-Item (Get-ChildItem -filter "*.jpg") -destination C:\new_path
###########
$a = Get-ChildItem -Recurse -Include "smth*"
Move-Item $a -destination "D:\new\path"
###########
# input
$a = 3
$b = 4
$c = $a + $b
# output
echo $c # 7
"result: $c" # result: 7
"$c" # 7
############
#############
$file = import-csv sample.csv # file to variable
$file[2] # get only second row
$file[0..3] # get specified rows
$file | select title # get only "title" column
$file | Select-Object title # get only "title" column
$file | Select-Object title, name # get "title" and "name" columns
get
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment