Еще пока сырой документ, но т.к. сам часто пользуюсь, выложу. Оригинал, от которого постепенно буду отходить в сторону лучшей структурированности и полезности: Basic shell commands by Jeremy Sanders Вообще, посмотрите на сайте, что там Джереми наваял, есть еще интересное :)
Все, что написано на русском языке, было проверено мной лично в терминале на Ubuntu 12.04LTS
- cat - Распечатать содержимое на экране. Можно использовать в связке с другими утилитами.
cat helloworld.py # Отобразить любопытный листинг в терминале cat file1 file2 file3 > outfile # собрать файлы в один cat *.txt > outfile # собрать все .txt файлы вместе cat egg.py spam.py | grep '\bdef\b' # найти в указанных файлах # все вхождения def - определения функции cat foo.py bar.py | sed -e 's/шило/мыло/g' > out.py # заменить в файлах шило на мыло и сохранить это в out.py
- cd - Сменить текущую директорию
cd # в домашнюю папку cd ~/books # /home/user/books cd ~dima # /home/dima cd somedir # в директорию относительно текущей cd /dir1/dir2/dir3... # в указанную абсолютно директорию cd - # в предыдущую директорию (аналог backspace в оконном менеджере) cd .. # в директорию уровнем выше
- mkdir - Создать директорию
mkdir testdir # в текущей папке появится testdir
- cp - Копировать файл(ы)
cp file1 file2 # копировать file1 в file2 cp file1 directory # копировать file1 в папку directory cp file1 file2 file3 ... directory # копировать несколько файлов в директорию cp *.txt myTextsDir # копировать все .txt файлы в директорию myTextsDir cp -R dir1 dir2/ # copy dir1 into dir2 including subdirectries cp -pR dir1 dir2/ # copy directory, preserving permissions
- date - Текущая дата и время
> date Вт. Сент. 24 16:14:46 MSK 2013
- chmod - Управление доступом
chmod +x script.py # делает script.py исполняемым файлом chmod -x script.py # script.py перестает быть исполняемым
- vim - Текстовый редактор, требует установки и изучения(!)
vim foo.txt # открывает файл для работы в терминале gvim foo.txt # открывает файл в отдельном окне # M-x start server first)
- file - Выводит информацию о типе файла
> file temp_70.jpg temp_70.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), 72 x 72
- gedit - Текстовый редактор gedit
gedit file.txt # открыть файл в gedit
- gnuplot - Пакет для построения графиков, требует дополнительной установки.
- grep - Ищет текст в файлах. Показывает список строк с
найденным текстом (с указанием имени файла, если ищем больше чем в одном файле).
grep "привет" file1 file2 ... # ищет текст 'привет' в указанных файлах grep -i "ПрИвЕТ" filename # регистронезависимый поиск cat filename | grep "hi there" # связать команды grep -v "ложь" filename # вывести строки, НЕ содержащие 'ложь' # кавычки могут быть одинарными
- sed - Потоковый текстовый редактор
sed -e 's/oldstuff/newstuff/g' inputFileName > outputFileName # типичное использование sed: # s - заменить # oldstaff - старое # newstaff - на новое # g - глобально, во всем документе inputFileNama # и затем это все дело сохранить в outputFileName
sed на википедии - cc или gcc - Компиляция программы на C
cc test1.c # компилирует test1.c в a.out cc -o test2.prog test2.c # компилирует test2.c в test2.prog, выходной файл после ключа -o # запуск программы ./a.out или соответственное название
- gtar - GNU version of the tar utility (also called tar
on Linux). Store directories and files together into a single
archive file. Use the normal tar program to backup files to a
tape. See info tar for documentation.
gtar cf out.tar dir1 # put contents of directory into out.tar gtar czf out.tar.gz dir1 # write compressed tar, out.tar.gz gtar tf in.tar # list contents of in.tar gtar tzf in.tar.gz # list contents of compressed in.tar.gz gtar xf in.tar # extract contents of in.tar here gtar xzf in.tar.gz # extract compressed in.tar.gz gtar xf in.tar file.txt ... # extract file.txt from in.tar
- gzip / gunzip - GNU Compress files into a smaller
space, or decompress .Z or .gz files.
gzip file.fits # compresses file.fits into file.fits.gz gunzip file.fits.gz # recovers original file.fits gzip *.dat # compresses all .dat files into .dat.gz gunzip *.dat.gz # decompresses all .dat.gz files into .dat program | gzip > out.gz # compresses program output into out.gz program | gunzip > out # decompresses compressed program output
- info - A documentation system designed to replace
man for GNU programs (e.g. gtar, gcc). Use cursor keys and
return to go to sections. Press b to go back to previous section. A
little hard to use.
info gtar # documentation for gtar
- kill - Kill, pause or continue a process. Can also be
used for killing daemons.
> ps -u jss ... 666 pts/1 06:06:06 badprocess > kill 666 # this sends a ``nice'' kill to the # process. If that doesn't work do > kill -KILL 666 # (or equivalently) > kill -9 666 # which should really kill it! > kill -STOP 667 # pause (stop) process > kill -CONT 667 # unpause process
- logout - Closes the current shell. Also try ``exit''.
- lp - Sends files to a printer
lp file.ps # sends postscript file to the default printer lp -dlp2 file.ps # sends file to the printer lp2 lp -c file.ps # copies file first, so you can delete it lpstat -p lp2 # get status and list of jobs on lp2 cancel lp2-258 # cancel print job lp2-258 lpr -Plp2 file.ps # send file.ps to lp2 lpq -Plp2 # get list of jobs on lp2 lprm -Plp2 1234 # delete job 1234 on lp2
- ls - Показать список файлов или информацию о них
ls file # проверить, существует ли ls -l file # показать информацию о файле ls *.txt # показать все файлы с расширением .txt ls -lt # показать информацию о всех файлах в директории в порядке создания ls -lrt # above reversed in order ls -a # показать все файлы, влючая скрытые ls dir1 # показать содержимое папки dir1 ls -d dir1 # существует ли папка dir1? ls -p # добавляет значащие символы к концам файлов ls -R # показывает файлы и в поддиректориях ls -1 # показывать 1 файл в каждой строке
- man - Справочная информация о командах
man man # справка о самом man man grep # справка о grep
- more - Показать файл последовательно по одному экрану
more file # показать file, следующий экран - пробел grep 'frog' file | more # сделать то же с выходом другой команды
- mv - Перемещает или переименовывает файлы
mv file1 file2 # переименовать file1 в file2 mv dir1 dir2 # переименовать папку dir1 в dir2 mv file1 file2 file3 ... directory # переместить файлы в папку directory
- nano - Очень простой текстовый редактор. Поддерживает подсветку кода и запускается прямо в терминале. Бывает удобно.
- nice - Start a process in a nice way. Nice levels run
from -19 (high priority) to 19 (low priority). Jobs with a higher
priority get more CPU time. See renice for more detail. You should
probably be using the grid-engine to run long jobs.
nice +19 myjob1 # run at lowest priority nice +8 myjob2 # run at lowish priority
- openoffice.org - a free office suite available for
Linux/Unix, Windows and Mac OS X.
- passwd - change your password
- pine - A commonly used text-based mail client. It is
now called alpine. Allows you to send and receive
emails. Configuration options allow it to become quite
powerful. Other alternatives for mail are mozilla mail and mutt,
however I suggest you stick to alpine or thunderbird.
- printenv - Print an environment variable in tcsh
setenv MYVARIABLE Fred printenv MYVARIABLE printenv # print all variables
- ps - List processes on system
> ps -u jss # list jss's processes 934 pts/0 00:00:00 bash ^^^^^ ^^^^^ ^^^^^^^^ ^^^^^^^ PID output CPU time name > ps -f # list processes started here in full format > ps -AF # list all processes in extra full format > ps -A -l # list all processes in long format > ps -A | grep tcsh # list all tcsh processes
- pwd - Текущая рабочая директория
> pwd /home/jss/writing/lecture
- renice - Renice a running process. Make a process
interact better with other processes on the system (see top to see
how it is doing). Nice levels run from -19 (high priority) to 19
(low priority). Only your own processes can be niced and they can
only be niced in the positive direction (unless you are
root). Normal processes start at nice 0.
> ps -u jss | grep bigprocess # look for bigprocess 1234 pts/0 99:00:00 bigprocess > renice 19 1234 # renice PID 1234 to 19
- rm - Удалить файлы
rm file1 # молча удаляет файл rm -i file # удалить файл, спросив перед этим y/n rm -r dir1 # удаляет папку и все в ней (осторожно с этим, детки!) rm -rf dir1 # то же самое, но не спрашивает, даже если поставить флаг -i
- rmdir - Удаляет директорию, если она пуста (rm
-r dirname удалит с содержимым)
rmdir dirname
- staroffice - An office suite providing word processor,
spreadsheet, drawing package. See Users' Guide on how to install
this. This is a commercial version of the openoffice office package
- use openoffice.org on linux.
- setenv - Set an environment variable in tcsh.
setenv MYVARIABLE Fred echo Hi there $MYVARIABLE
- tar - Combine files into one larger archive file, or
extract files from that archive (same as gtar on Linux).
tar cvf /dev/rmt/0 ./ # backup cwd into tape tar tvf /dev/rmt/0 # list contents of tape tar xvf /dev/rmt/0 # extract contents of tape
- thunderbird - Почтовая программа mozilla thunderbird.
- top - Interactively show you the ``top'' processes on a
system - the ones consuming the most computing (CPU) time. Press the
``q'' key in top to exit. Press the ``k'' key to kill a particular
process. Press ``r'' to renice a process.
- sudo apt-get remove program - Удалить программу program из системы