Related to files
MOVE
mv path path
COPY
cp path path
REMOVE
rm file
rm -r folder
UNTAR
tar -xvzf file.tar.gz
tar -xvjf file.tar.tbz
or install dtrx
REDIRECT
> redirects stdout to file and overwrites
>> redirects stdout to file and appends
< redirects stdin to a command
PIPE
| gives the output of a command as input to another command
LIST FOLDERS
ls -d */
LIST FILES WITH SIZE
ls -lhS
FIND FILE
find -iname "filename"
GREP
find text in file/text
dpkg --list | grep PACKAGE
case insensitive
grep -i ...
find text in files
grep -R wordtofind /home/luke
SORT
sort text.txt > sorted-text.txt
UNIQ
uniq text.txt > uniq-text.txt
REPLACE TEXT
replace only first occurrence on each line
sed 's/texttofind/textreplace/' text.txt
replace all (add g)
sed 's/texttofind/textreplace/g' text.txt
REMOVE A LINE IF CONTAINS PATTERN
awk '!/patterntofind/' file1 > file2
sed '/patterntofind/d' ./file1 > ./file2
Related to disks
MOUNT
sudo mount -t vfat /dev/sdb1 /media (FAT)
sudo mount /dev/sdb1 /media (ext)
sudo mount -t ntfs /dev/sdb1 /mnt/drive (NTFS)
UNMOUNT
sudo umount /path
AVAILABLE SPACE
df -Bm
LIST PARTITONS (needs parted)
sudo parted
print all
CLONE A DISK
sudo dd if=/dev/sdb of=/dev/sdc bs=4096 conv=notrunc,noerror
WRITE AN IMAGE ON A DISK
sudo dd if=sdcard.img of=/dev/sdb
Related to the computer
AVAIL RAM
free -m
CPU USAGE
top
GET CPU INFO
cat /proc/cpuinfo
CHECK BATTERY POWER
cat /sys/class/power_supply/BAT0/power_now
LIST DRIVERS
lsmod
GET DRIVER INFO
modinfo MODULE
GET ENV INFO
env
LIST USB DEVICES
lsusb
GET CPU TEMP
Raspberry Pi
vcgencmd measure_temp
PC
cat /sys/class/thermal/thermal_zone0/temp
Related to packages
LIST INSTALLED PACKAGES (with version and info)
dpkg --list | grep PACKAGE
INSTALL DEB PACKAGE
sudo dpkg -i PACKAGE
sudo apt-get install -f
DOWNLOAD A GIT FOLDER
git clone <url>
Related to network
LIST NETWORK ADAPTERS
ifconfig
LIST WIFI ADAPTERS
iwconfig
SCAN WIFI
iwlist wlan0 scan
CONNECT TO WPA WIFI
wpa_passphrase NETWORKSSID > wpa.conf
then enter password
then enter password
sudo wpa_supplicant -B -Dwext -iwlan0 -c wpa.conf
sudo dhclient -r
sudo dhclient wlan0
No comments:
Post a Comment