Cygwin下編譯的程序不使用Cygwin.dll便可運行的命令 及經常使用命令簡介

cc -mno-cygwin foo.chtml

 

一、$ pslinux

PS的相關用法:ios

Quote
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processesshell

 

二、DF命令直接查看下本地驅動器vim

$ df
Filesystem 1k-blocks Used Available Use% Mounted on
c: 5106676 1240312 3866364 25% /cygdrive/c
d: 10239408 6560328 3679080 65% /cygdrive/d
e: 10231384 4844432 5386952 48% /cygdrive/e
在後面的/cygdrive/c即是C盤了windows

 

三、CD命令改變當前路徑 less

進D盤ui

$ cd /cygdrive/dthis

 

四、Cygwin下運行Windows程序spa

$ cmd.exe
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

e:\cygwin\home\Taynni-417>d:

D:\>cd hacker

D:\HACKER>cd tools

D:\HACKER\Tools>cd pstools

D:\HACKER\Tools\Pstools>exit

直接輸入CMD.EXE即可以獲得一個本機CMDSHELL,這樣運行什麼程序均可以

退出到Cygwin的Bash shell須要使用exit命令

 

五、--help 幫助命令

--help獲取幫助

$ md5sum --help

Usage: md5sum [OPTION] [FILE]...
or: md5sum [OPTION] --check [FILE]
Print or check MD5 (128-bit) checksums.
With no FILE, or when FILE is -, read standard input.

-b, --binary read files in binary mode (default on DOS/Windows)
-c, --check check MD5 sums against given list
-t, --text read files in text mode (default)

The following two options are useful only when verifying checksums:
--status don't output anything, status code shows success
-w, --warn warn about improperly formated checksum lines

--help display this help and exit
--version output version information and exit

The sums are computed as described in RFC 1321. When checking, the input
should be a former output of this program. The default mode is to print
a line with checksum, a character indicating type (`*' for binary, ` ' for
text), and name for each FILE.

 

六、 經常使用命令
       在Bash shell的命令行交互中能夠輸入不少命令運行。例如:
命令 說明   命令 說明
touch 新建文件   cmd 切換到windows控制檯,能夠運行windows程序
rm 刪除文件   --help 參數,顯示命令幫助
mkdir 新建目錄   man 顯示命令幫助
rmdir 刪除目錄   info 顯示命令更詳細幫助
ls 顯示文件和目錄   ps 顯示進程
cd 改當前目錄 cd /   echo 輸出變量值,echo $PATH
cp 複製文件   find 查找文件
mv 移動文件   diff 比較文件差別
查看命令幫助文檔時,按 Ctrl+Z 或 Ctrl+C 退出命令
更多命令參考:http://linux.chinaitlab.com/special/linuxcom/Index.html

pwd   顯示當前的路徑

cd    改變當前路徑,無參數時進入對應用戶的home目錄
ls    列出當前目錄下的文件。此命令有N多參數,好比ls -al
ps    列出當前系統進程
kill 殺死某個進程
mkdir 創建目錄
rmdir 刪除目錄
rm    刪除文件
mv    文件更名或目錄更名
man   聯機幫助
less 顯示文件的最末幾行
因爲linux下面的命令大多都有不少參數,能夠組合使用。因此,每當你不會或者記不清楚該用哪一個參數,哪一個開關的時候,能夠用man來查找

好比,查找ls怎麼使用,能夠鍵入

$ man ls
系統回顯信息以下:
LS(1)                          FSF                          LS(1)

 

七、編譯helloworld

# cd
進入了/home/administrator目錄,我當前的登錄賬號是administrator
# mkdir source
創建一個叫作source的子目錄
# cd source
進入 /home/administrator/source
# vim hello.c
咱們編輯hello.c文件,輸入:

1 #include <stdio.h>
2 int main(void){
3         printf("Hello world!\r\n");
4         return 0;
5 }

 

而後,Esc並輸入:wq命令退到命令行。

輸入編譯指令:
# gcc hello.c -o hello
編譯成功後能夠看一下
# ls
看到hello.exe了吧

 

C++的Hello world

# vim world.cpp
輸入:

1 #include <iostream>
2 using namespace std;
3 int main(void){
4         cout<<"Hello World!!!";
5         cout<<"\n";
6         return 0;
7 }

編譯C++程序要用g++

# g++ world.cpp -o world
運行一下
# ./world

好了,關於如何編寫makefile文件,如何用gdb下次再說了。

Linux開發一路過來 cygwin->make->gcc

相關文章
相關標籤/搜索