DIRECTORY OF WINDOWS COMMAND LINE

DIRECTORY OF WINDOWS COMMAND LINE

Command line for the system administrator - like a knife to cook: you can do without, but by using it, the work becomes much more convenient. Unfortunately not always have the opportunity to remember all the commands that are useful, but needs to work only from time to time. A list of these commands is easy to hold in the form of a small handbook, which is convenient to handle if necessary.

Back to top

Navigating through directories

Team Description
cd — Go to previous directory
cd Go to $ HOME directory
(cd dir && command) Go to the directory of the dir , execute command and return to current dir . && design allows you to combine commands vtraya Komada is performed only in the case of successful completion of the previous command.
pushd . Put current dir on stack, to later return to it with popd
popd get out of the stack directory.
alias l = 'ls -l -color = auto' Quickly displaying a content directory.
Then simply enter the l command and press Enter
ls -lrt The list of files sorted by date. See. Also newest and find_mm_yyyy
ls /usr/bin | pr -T9 -W$COLUMNS Print to 9 columns in the terminal width
find /var/www -t d -exec chmod 755 {} \; Inside / var / www, folders only, Make 755 permissions
sudo find /var/www -t f -exec chmod 644 {} \; Inside / var / www, files only, Make 644 permissions
find -name ‘*.[ch]’ | xargs grep -E ‘expr’ Search 'expr' in the current directory and in the lower directories. See. Also findrepo
find -type f -print0 | xargs -r0 grep -F ‘example’ Search all files for 'example' in this dir and below
find -maxdepth 1 -type f | xargs grep -F ‘example’ Search all files for 'example' in the current directory
find -maxdepth 1 -type d | while read dir; do echo $dir; echo cmd2; done Process each element with multiple commands (in the while loop)
find -type f ! -perm -444 Find files that are not readable by all (useful for web site)
find -type d ! -perm -111 Find dirs not accessible by all (useful for web site)
locate -r ‘file[^/]*\.txt’ Search cached index for names.
look reference Quickly search (sorted) dictionary for prefix
grep —color reference /usr/share/dict/words Highlight occurances of regular expression in dictionary
Back to top

Archiving and compression

Team Description
gpg -c file encrypt file
gpg file.gpg decrypt the file
tar -c dir / | bzip2> dir.tar.bz2 Archive directory (folder) dir /
bzip2 -dc dir.tar.bz2 | tar -x Extract archive (use gzip instead of bzip2 for tar.gz files)
tar -c dir/ | gzip | gpg -c | ssh [email protected] ‘dd of=dir.tar.gz.gpg’ To create an encrypted archive to a directory (folder) dir / on remote computer
find dir/ -name ‘*.txt’ | tar -c —files-from=- | bzip2 > dir_txt.tar.bz2 Create archive for dir / folders and all subfolders
find dir/ -name ‘*.txt’ | xargs cp -a —target-directory=dir_txt/ —parents Create a copy of the folder dir / a subfolder
( tar -c /dir/to/copy ) | ( cd /where/to/ && tar -x -p ) Copy (with permissions) copy / folder to / where / to /
( cd /dir/to/copy && tar -c . ) | ( cd /where/to/ && tar -x -p ) Copy (with permissions) contents of copy / dir to / where / to
( tar -c /dir/to/copy ) | ssh -C [email protected] ‘cd /where/to/ && tar -x -p’ Copy (with permissions) copy / dir to remote computer remote: / where / to
dd bs=1M if=/dev/sda | gzip | ssh [email protected] ‘dd of=sda.gz’ Make a backup of your hard drive and send it to a remote computer
Back to top

ssh

   
Team Description
ssh [email protected]$HOST command Run the command on the remote host $ HOST as user $ the USER
(the default command = shell)
ssh -f -Y [email protected]$HOSTNAME xeyes Run GUI command on $ HOST host name of the user $ USER
scp -r -p $ USER @ $ HOST: file dir / Copy the folder dir / s access rights in the user's home directory on the host $ USER $ HOST
ssh -g -L 8080:localhost:80 [email protected]$HOST Forward connections to $ HOSTNAME: 8080 out to $ HOST: 80
ssh -R 1434:imap:143 [email protected]$HOST Forward connections from $ HOST: 1434 in to. imap: 143
Back to top

wget (multi purpose download tool)

   
Team Description
(cd cli && wget -nd -pHEKk http://www.pixelbeat.org/cmdline.html) Save the Web page (as it was called locally) in the current directory
wget -c http://www.example.com/large.file Continue downloading a partially downloaded file
wget -r -nd -np -l1 -A ‘*.jpg’ http://www.example.com/ Download a lot of files in the current directory
wget ftp://remote/file[1-9].iso/ Ftp supports globbing directly
wget -q -O- http://www.pixelbeat.org/timeline.html | grep ‘a href’ | head Output directly (on screen)
echo ‘wget url’ | at 01:00 Download url at 01:00 in the current directory
wget —limit-rate=20k url Make download a reduced speed (limit to 20KB / s in this example)
wget -nv —spider —force-html -i bookmarks.html Check links in a file
wget —mirror http://www.example.com/ Efficiently update a local copy of a site (handy from cron)
Back to top

mathematical operations

Team    Description
echo ‘(1 + sqrt(5))/2’ | bc -l Simple mathematics (Calculation of φ). See. Also bc
echo 'pad = 20; min = 64; (100 * 10 ^ 6) / ((pad + min) * 8) '| bc More complex (int). This example shows the maximum FastE packet rate
echo 'pad = 20; min = 64; print (100E6) / ((pad + min) * 8) '| python Python is engaged in mathematical calculations
echo ‘pad=20; plot [64:1518] (100*10**6)/((pad+x)*8)’ | gnuplot -persist Print FastE packet rate versus packet size
echo ‘obase=16; ibase=10; 64206’ | bc Base conversion (decimal to hexadecimal)
echo $((0x2dec)) Base conversion (hexadecimal to decimal)
((arithmetical expansion shell-a))
units -t ‘100m/9.58s’ ‘miles/hour’ Unit conversion (metric system to imperial)
units -t ‘500GB’ ‘GiB’ Unit conversion (SI in IEC prefixes)
units -t ‘1 googol’ Search definition
seq 100 | (tr ‘
‘ +; echo 0) | bc
Add a column of numbers. See. Also add and funcpy
Back to top

rsync (Network efficient file copier: Use the -dry-run option for testing)

Team Description
rsync -P rsync://rsync.server.com/path/to/file file Only display the differences. Do multiple times for troublesome injection
Rsync -bwlimit = 1000 fromfile tofile Copy locally limiting velocity. It's nice for I / O
rsync -az -e ssh -delete ~ / public_html / remote.com:'~/public_html ' Mirror web site (using compression and encryption)
rsync -auz -e ssh remote:/dir/ . && rsync -auz -e ssh . remote:/dir/ Synchronize current directory with remote computer
Back to top

Network Commands (Note that ifconfig command, route, mii-tool, nslookup obsolete)

Team Description
ethtool eth0 Display the status of a network device (interface) eth0
ethtool —change eth0 autoneg off speed 100 duplex full Manually set the speed of the network interface (device)
iwconfig eth1 Display wireless interface status (device) eth1
iwconfig eth1 rate 1Mb/s fixed Manually set the speed of the wireless interface (device)
iwlist scan The list of wireless networks within range
ip link show List of network interfaces (devices)
ip link set dev eth0 name wan Rename interface (device) eth0 to wan
ip link set dev eth0 up Activate interface eth0 (to turn - down)
ip addr show List ip interface addresses
ip addr add 1.2.3.4/24 brd + dev eth0 Add (or remove) the ip address and subnet mask (255.255.255.0)
ip route show Print the routing table
ip route add default via 1.2.3.254 1.2.3.254 Set as the default gateway
tc qdisc add dev lo root handle 1:0 netem delay 20msec Add 20ms latency to the device loopback (test)
tc qdisc del dev lo root Remove latency added above
host pixelbeat.org DNS ip address lookup by host name or vice versa
hostname -i Search local ip address (identical to the host 'hostname')
whois pixelbeat.org whois search for information on the host name or ip address
netstat -tupl List of internet services in the system
netstat -tup List of active compounds to a system (the system)
netstat -a list of network connections
netstat -an list of network connections, without defining domain name host
netstat -anp list of network connections, without identifying the name of the host process
smbtree Find windows machines. See. Also findsmb
nmblookup -A 1.2.3.4 Find windows (netbios) name associated with ip address
smbclient -L windows_box List shares on windows machine or samba server
mount -t smbfs -o fmask=666,guest //windows_box/share /mnt/share Mount windows share (with public access folder)
echo ‘message’ | smbclient -M windows_box Send popup to windows machine (off by default in XP sp2)
sudo pdbedit -L -v List of members of the Samba server
Back to top

Text Manipulation

Team Description
BUT  
sort -t. -k1,1n -k2,2n -k3,3n -k4,4n Sort IPV4 ip address
echo ‘Test’ | tr ‘[:lower:]’ ‘[:upper:]’ Transfer from one register to another
tr -dc ‘[:print:]’ < /dev/urandom Filter not printable characters
history | wc -l Calculate the number of rows in this case, command history
Back to top

Set operations (Note you can export LANG = C for speed. This also assume no duplicate lines within a file)

Team Description
sort file1 file2 | uniq Union of unsorted files
sort file1 file2 | uniq -d Intersection of unsorted files
sort file1 file1 file2 | uniq -u Difference of unsorted files
sort file1 file2 | uniq -u Symmetric Difference of unsorted files
join -t’\0′ -a1 -a2 file1 file2 Union of sorted files
join -t’\0′ file1 file2 Intersection of sorted files
join -t’\0′ -v2 file1 file2 Difference of sorted files
join -t’\0′ -v1 -v2 file1 file2 Symmetric Difference of sorted files
Read more:   How to create a file SITE MAP

The calendar

Team Description
must -3 Show calendar
9 need 1752 Display a calendar for a particular month of the year
date -d fri What date is it this friday. See. Also day
[ $(date -d «tomorrow» +%d) = «01» ] || exit To complete the script, unless it's the last day of the month
date —date=’25 Dec’ +%A What day will Christmas this year
date —date=’@2147483647′ Translate seconds elapsed since epoch (1970-01-01 UTC) on the date
TZ=’:America/Los_Angeles’ date What time is it on West coast of US (use tzselect to find TZ)
echo «mail -s ‘get the train’ [email protected] < /dev/null» | at 17:45 Reminding of Email
echo «DISPLAY=$DISPLAY xmessage cooker» | at «NOW + 30 minutes» Reminding in Popup window
Back to top

Information about the system (see. Also sysinfo) ( '#' means that are necessary to run root-and rights)

   
Team Description
uname -a Show kernel version and system architecture
head -n1 /etc/issue Show name and version of distribution (operating system)
cat /proc/partitions Show all partitions registered on the system
grep MemTotal /proc/meminfo Show RAM total seen by the system
grep «model name» /proc/cpuinfo Show information on the processor (s) (CPU)
lspci -tv Show information on the PCI bus
lsusb -tv Show information about USB
mount | column -t List of mounted file systems in the system (herarhichesky output)
dmidecode -q | less Display information about the SMBIOS / DMI
smartctl -A /dev/sda | grep Power_On_Hours What is the amount of time it (the system) was included (served)
hdparm -i /dev/sda Show information about disk sda
hdparm -tT /dev/sda Test the read speed on disk sda
badblocks -s /dev/sda Test for unreadable disk blocks sda
Back to top

local

   
Team Description
printf «%’d
» 1234
Print number with thousands grouping appropriate to locale
BLOCK_SIZE=\’1 ls -l Get ls to do thousands grouping appropriate to locale
echo «I live in locale territory» Get information from the database locale
LANG = locale en_IE.utf8 int_prefix Search locale information for a particular country See. Also ccodes
locale | cut -d= -f1 | xargs locale -kc | less The list of fields available in the database locale data
Back to top

Rips (iconv command, dos2unix, unix2dos obsolete)

   
Team Description
recode -l | less Show available conversions (1 alias per line)
recode windows-1252.. file_to_change.txt Translate Windows "ansi" to local (current) charset (auto does CRFL translation)
recode utf-8/CRLF.. file_to_change.txt Transfer windows utf8 in the local (current) kodiruvku
recode iso-8859-15..utf8 file_to_change.txt Translate from latin9 encoding (Western European) in utf8
recode ../b64 < file.txt > file.b64 base64 encoding
recode /qp.. < file.txt > file.qp Decoding with quotes
recode ..HTML < file.txt > file.html Translate text in the HTML
recode -lf windows-1252 | grep euro Search in the symbol table
echo -n 0x80 | recode latin-9/x1..dump Show character encoding latin9 code
echo -n 0x20AC | recode ucs-2/x2..latin-9/x Show latin-9 encoding
echo -n 0x20AC | recode ucs-2/x2..utf-8/x Show utf-8 encoding
Back to top

CDs (CD operations with disks)

   
Team Description
gzip < /dev/cdrom > cdrom.iso.gz Save a copy of a data CD
mkisofs -V LABEL -r dir | gzip > cdrom.iso.gz Create an image of the CD from the contents of a directory
mount -o loop cdrom.iso /mnt/dir Mount the CD image to / mnt / dir (read only)
cdrecord -v dev=/dev/cdrom blank=fast Clear CDRW
gzip -dc cdrom.iso.gz | cdrecord -v dev=/dev/cdrom — Burn CD image (use dev = ATAPI -scanbus to select the recording device)
cdparanoia -B Save audio CD tracks to wav files (saved in the current folder)
cdrecord -v dev=/dev/cdrom -audio *.wav Create an audio CD (audio CD) of all the wav files
in the current directory (see. Also cdrdao)
oggenc —tracknum=’track’ track.cdda.wav -o ‘track.ogg’ Make ogg file from wav file
Back to top

Monitoring / Debugging

   
Team Description
tail -f /var/log/messages Monitoring messages in the log file
strace -c ls >/dev/null Amount / profile system calls made by command
strace -f -e open ls >/dev/null A list of system calls made by command
ltrace -f -e getenv ls >/dev/null List library calls made by command
lsof -p $$ List paths that process id has open
lsof ~ List processes that have specified path open
tcpdump not port 22 Display network (except ssh) traffic. See. Also tcpdump_not_me
PS -as -a pid, args -forest A hierarchical list of processes
PS -to -the pcpu, cpu, nice, state, cputime, args -sort pcpu | sed '/ 0.0' / ​​d ' Process list with CPU%
ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS List processes by mem usage (See. also ps_mem.py)
ps -C firefox-bin -L -o pid,tid,pcpu,state List all threads for a particular process
1.2 ps -p List of information for particular process IDs (identifiers)
last reboot Show system reboot history
free -m Show the amount of remaining memory (-m displays in megabytes)
watch -n.1 ‘cat /proc/interrupts’ Watch for successively varying data
C3 ionic bash Bash advances the process to the input-output mode idle (idle mode)
-c, -class class (0 for none, one for realtime, 2 for best-effort, 3 for idle.)
Back to top

Disk space (See. Also FSlint)

   
Team Description
ls -lSr The list of files, sorted by size (largest file size - the latter)
You -s * | variety -k1,1rn | head Show users in the current folder with the largest amount of data used.
See. Also dutop
df -h Show free space on mounted filesystems
df -i Show free inodes on mounted filesystems
fdisk -l Show disks partitions sizes and types (run as root-a)
rpm -q -a —qf ‘%10{SIZE}\t%{NAME}
‘ | sort -k1,1n
List of all packages with a size distribution (size - in Bytes)
dpkg-query -W -f=’${Installed-Size;10}\t${Package}
‘ | sort -k1,1n
List all packages by installed size (size - in kilobytes) for debian distros
dd bs=1 seek=2TB if=/dev/null of=ext3.test Create a large test file. See. Also truncate
Back to top

Interactivity (see. Also hotkeys linux)

   
Team Description
readline Line editor used by bash, python, gnuplot, ...
screen Virtual terminals with detach capability, ...
mc A powerful file manager that can browse rpm, tar, ftp, ssh, ...
gnuplot Interactive (scripting) schedule
links Text Web browser
Back to top

Active directory

   
ldifde -f export.ldf -d «CN=Users,DC=test,DC=home» Exports all the elements of the org. Units Users
Back to top

PowerShell

   
(Get-Item "$env:windir").creationtime 
Dasts create the Windows directory
gci d: -force | where {$_.creationtime -lt "15.11.2013" -and $_.creationtime -gt "16.11.2013"} | 
select fullname,creationtime | sort creationtime
It displays a list of child items in the folder, selects only date that meets the criteria, sorted by creation date. Key -force instructs also display hidden and system files.
Back to top

miscellanea

   
Team Description
alias hd = 'od -Ax -tx1z -v' 16 Manual Hex Dump (Example use: hd / proc / self / cmdline | less)
alias realpath=’readlink -f’ Canonical pathway (Example use: realpath ~ /../$ USER)
set | grep $USER Search in the current environment (environment)
touch -c -t 0304050607 file Set the date for the file (YYMMDDhhmm)
python -m SimpleHTTPServer Display a tree of the current directory at http: // $ HOSTNAME: 8000 /
apropos whatis Show commands pertinent to string. See. Also threadsafe
man -t man | ps2pdf — > man.pdf Create a pdf version of the manual pages (man)
which command Show full path to the command file
update-rc.d Управление запуском сервисов в Ubuntu Linux
update-rc.d [-n] [-f] name remove
update-rc.d [-n] name defaults [NN | SS KK]
update-rc.d [-n] name start|stop NN runlevel [runlevel]…
start|stop NN runlevel [runlevel]… . …
update-rc.d [-n] name disable|enable [ S|2|3|4|5 ]
time command Execute the command and display runtime
time cat Start the stopwatch. Ctrl-d to stop it. See. Also sw
nice info Start command with the low priority ( "info" reader in this case)
renice 19 -p $$ Set shell (script) low priority. Used for non interactive tasks.
disper —cycle-stages=’-S : -s’ —cycle Switching between the monitors connected to the system
iptables -t nat -A PREROUTING -i eth0 -p tcp —dport 5555 -j NAT —to 10.10.1.1:3389 ICING RDP packets from outside to inside.
Read more:   CREATE A NEW WEBSITE FOR TIMEWEB

 

Back to top

DIR command

DIR command is used to display information about the contents of directories and disks. This command has the following syntax: DIR [drive:] [path] [filename] [/ A [[:] attributes]] [/ B] [/ C] [/ D] [/ L] [/ N] [/ O [[:] sorting order]] [/ P] [/ Q] [/ R] [/ S] [/ T [[:] time]] [/ W] [/ X] [/ 4] [drive: ] [path] [filename].

As can be seen from the syntax, DIR command can be used without parameters. In this case, the DIR command operates on the current directory. The screen displays the disk label (volume), the serial number, the names of files and subdirectories in the current directory and the date they were last modified. For files that indicate their size, the total number. It also indicates the total number of files and free space on the disk. For example, DIR command is applicable to «C» the disc: the dir

to you

If only the [drive:] is used in the DIR command, the screen contents of the disc will be displayed. If the team has used the [drive:] [catalog], then the screen contents of the directory will be displayed. If the team has used the [drive:] [directory] [file name], then the screen will display information about a file or group of files. For example, to display the contents of the disc «D»: dir d: \ ( either dir d: )

to you.

Will create on the disk «D» folder «FOLDER» and put into it 2 «Folder1» folder and «Folder2», as well as the file «myfolder.txt». Then the team dir d: \ FOLDER will display information about the contents of the directory «FOLDER».

to you..

Team dir d:. \ FOLDER \ * txt will display information on the screen of text files, located in the «FOLDER» folder.

to you...

Key / P used in the event that the contents of the disk or directory does not fit on one screen. For example, to display the contents of the directory «the Windows»: the dir windows / p

to you....

The screen will display information about the contents of the Windows directory. Because all the contents will not fit in one screen, use the key / P. press any key to display the next screen.

Read more:   HOW TO INSTALL UBUNTU In VMWARE WORKSTATION

Key / W is used if you want to display a list of files and directories in a single row with the maximum possible number of them can fit on the screen (wide format). Files and folders are displayed in alphabetical order (sorted by rows). For example, to display the contents of the "C" drive: the dir / of w

dir3 ....

Key / D similar to the previous key / W, but in this case, sorting is performed on poles. Displays the contents of a disk "C»: the dir / d

dir3 .....

Key / A: [attributes] is used to display information about the files and folders that have the specified attributes. Attributes can be:

  • H - displays the hidden files and folders
  • S - displays the system files and folders
  • R - displays the files and folders, with the attribute "read only"
  • A - displays the files and folders from the archive attribute set
  • I - displays the files and folders with non-indexed content

For example, suppose that the disk «D» has «FOLDER» folder. It contains 2 «Folder1» folder and «Folder2», and «myfolder.txt» file. Install for "Folder2" folder and file «myfolder.txt» attribute "hidden". Then the team dir d: \ FOLDER a: h will display only information about these hidden files.

dir2

Key / A can be used with more than one attribute value. For example, display information about folders and files located on the disk "C" and having, at the same time, the attributes "hidden" and "system": the dir / a: hs

dir2.

Please note that displays the files and folders that have the attributes "hidden" and "system" at the same time .

If you put a sign in front of the attributes "-", then the screen will display information about the files and folders that have the specified attribute. For example, the command dir / a: -r displays information about files and folders located on a «C» the disc and do not have the attribute "read only".

dir2 ...

If the key / A to use a «D» option, then the screen will display information only and directories. For example, the command dir / a: d displays the information on the "C" drive directory, but will not display information about the files.

dir2 ....

Accordingly, if we need to display only files, use a key / -D. For example, display the files on the disk "C»: the dir / a: -d

DIR4

By default (without a key / A), DIR command displays the names of all the folders and files except hidden and system. When you use the DIR command with the key / A with no parameters, it displays the names of all the folders and files. For example, the command dir / a displays the names of all the folders and files (including hidden and system files) in the current directory.

Key / S allows you to display information about the files in a given directory and its subdirectories. For example, to create a disc «D» folder «FOLDER», to put it another 2 «Folder1» folders and «Folder2». In each of the 3 folders put one file. Then the command dir d: \ FOLDER / s displays the contents of the main folders «FOLDER» and all subfolders «Folder1» and «Folder2».

dir2 .....


Previous article: XCOPY command (continued).
Contents: Command Prompt.
Next article: DIR command (continued).



Read in other languages

 BelorussianEnglish Deutsch Spanish French Italian Portuguese Turkish Arab Ukrainian Swedish Hungarian Bulgarian Estonian Chinese (Simplified) Vietnamese Romanian Thai Slovenian Slovak Serbian Malay Norwegian Latvian Lithuanian Korean Japanese Indonesian Hindi Hebrew Finnish Greek Dutch Czech Danish Croatian Chinese (Traditional) Philippine Urdu Azeybardzhansky ArmenianPolish Bengal Georgian Kazakh Catalan Mongolski Russian Tadzhitsky Tamilʹskij telugu Uzbetsky

Add a comment

Your e-mail will not be published. Required fields are marked *