LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-22-2016, 01:07 PM   #1
monahanz
LQ Newbie
 
Registered: May 2016
Posts: 6

Rep: Reputation: Disabled
Easiest way to have "DIR" work in Linux


From the above I'm clearly a newbie and a windows user.

My simple question is: what is the absolutely easiest way to have some kind of script so the "DIR: on the command line displays the current Linux directory as in windows. I'm currently using the Edison "Yocto" Linux version. As a windows user - - - not wishing to flame --- I find the Linux command line names totally scrambled letters. How for example does "df" get to be show the current directory? Has anybody out there written a type of script that makes it easy for Windows/DOS "die-hards" to use their favorite commands like dir, copy, erase, show, type.. in Linux.

John
 
Old 05-22-2016, 01:31 PM   #2
sean.ferguson
LQ Newbie
 
Registered: Feb 2012
Location: Scotland
Distribution: Ubuntu 16.04 / Debian 8 / Arch
Posts: 25

Rep: Reputation: Disabled
Have a look into aliases on linux, you can easily set 'Dir' to become an alias of 'ls'
 
Old 05-22-2016, 01:46 PM   #3
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 763
Blog Entries: 3

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
Quote:
Originally Posted by monahanz View Post
From the above I'm clearly a newbie and a windows user.

My simple question is: what is the absolutely easiest way to have some kind of script so the "DIR: on the command line displays the current Linux directory as in windows. I'm currently using the Edison "Yocto" Linux version. As a windows user - - - not wishing to flame --- I find the Linux command line names totally scrambled letters. How for example does "df" get to be show the current directory? Has anybody out there written a type of script that makes it easy for Windows/DOS "die-hards" to use their favorite commands like dir, copy, erase, show, type….. in Linux.

John
Hi and welcome!

df does not show the current directory, pwd does however. Like the first answer says, you can alias commands to point to other commands.

For example, the aliases in my .bashrc under Arch Linux looks like this:
Code:
alias rm='rm -i'
alias grep='grep --color=auto'
alias mv='mv -v'
alias cp='cp -v'
alias wm='sudo wifi-menu'
So, you could for instance make an alias that looks like this:
Code:
alias Dir='pwd'
Then when you enter Dir on the command line, you will in reality run pwd and get your current working directory.

Best regards,
HMW

Last edited by HMW; 05-22-2016 at 01:48 PM.
 
1 members found this post helpful.
Old 05-22-2016, 02:26 PM   #4
af7567
Member
 
Registered: Nov 2012
Posts: 197

Rep: Reputation: 61
Make a few aliases like HMW says, but the correct command to make a dir alias like the DOS one would be
Code:
alias dir='ls -l'
To find out what a command does, use the man command from your terminal. Eg to read what the 'ls' command does try this
Code:
$ man ls
Some other commands you might want to check the man pages for are cd, mv, rm, cp, and cat
 
1 members found this post helpful.
Old 05-22-2016, 04:03 PM   #5
monahanz
LQ Newbie
 
Registered: May 2016
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks guy's that helps a bit, the alias dir='ls -l' seem to be the closest. The first picture below is what I get.

It sort of gives me more information than I (normally) need. Is there a program out there that lists just the file names and the sub directories with something like a / in front of the sub directory? For example the Edison "Yocto" Linux version of "df" is shown in the second picture below

BTW there does not seem to be a man ls command. What is the equivalent of Help xxx in Linux?

Finally is there a logic to the letters used and the commands in Linux. How does one get show the directory from ls?
Please excuse the basic questions these I think would be typical of a first time windows user.
Attached Thumbnails
Click image for larger version

Name:	Edison ls.JPG
Views:	17
Size:	132.4 KB
ID:	21853   Click image for larger version

Name:	Edison df-Tree.JPG
Views:	19
Size:	66.1 KB
ID:	21854  
 
Old 05-22-2016, 04:15 PM   #6
sean.ferguson
LQ Newbie
 
Registered: Feb 2012
Location: Scotland
Distribution: Ubuntu 16.04 / Debian 8 / Arch
Posts: 25

Rep: Reputation: Disabled
files and sub-directories... try "ls -R" and see how this looks to you. It can get very messy but perhaps i missunderstand what you are trying to achieve.
 
Old 05-22-2016, 04:31 PM   #7
af7567
Member
 
Registered: Nov 2012
Posts: 197

Rep: Reputation: 61
Quote:
Originally Posted by monahanz View Post
BTW there does not seem to be a man ls command. What is the equivalent of Help xxx in Linux?

Finally is there a logic to the letters used and the commands in Linux. How does one get show the directory from ls?
Please excuse the basic questions these I think would be typical of a first time windows user.
The man command is the Linux equivalent of help I would have expected all distributions to have it unless you are running a minimal installation. You could also try the info command. If you search google for "basic linux commands" you will probably find some explanations for the names. I didn't really think about it much but to me ls looks like it means LiSt, cp is CoPy, mv is MoVe.

http://www.comptechdoc.org/os/linux/..._ugbasics.html
 
1 members found this post helpful.
Old 05-22-2016, 05:14 PM   #8
Soadyheid
Senior Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Distribution: Cinnamon Mint 17.3 and 18 at present.
Posts: 1,259

Rep: Reputation: 270Reputation: 270Reputation: 270
Quote:
Finally is there a logic to the letters used and the commands in Linux.
Of course... Here are a few others:

df is Disk File system space usage, usually with a -h switch so humans can read.

ls LiSt directory contents as mentioned above.

ps (with switches) report process status

pwd print name of Present Working Directory

cd change directory (Where have I seen this before?)

rm Remove or delete a file

shutdown Naw, you'll have to guess this one...

I'd say the commands are fairly similar to DOS in their quirkiness.

Play Bonny!

 
1 members found this post helpful.
Old 05-22-2016, 05:58 PM   #9
Krisburns
LQ Newbie
 
Registered: May 2016
Posts: 2

Rep: Reputation: Disabled
Quote:
Originally Posted by monahanz View Post
Is there a program out there that lists just the file names and the sub directories with something like a “/” in front of the sub directory? For example the Edison "Yocto" Linux version of "df" is shown in the second picture below

Code:
du -h --max-depth=1
This will give you a listing of your directories with a forward ./ in front of them along with a human readabe directory size on the left column.

Code:
ls -1F
This will give you a single column listing of your files and directories with a forward slash after a directory name.

Whichever code you use, pipe the code to either more or less because without it, the output will zoom quickly on the screen.

Code:
du -h --max-depth=1 | more
or
du -h --max-depth=1 | less

Last edited by Krisburns; 05-22-2016 at 06:09 PM.
 
1 members found this post helpful.
Old 05-22-2016, 08:30 PM   #10
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 12,379
Blog Entries: 16

Rep: Reputation: 3150Reputation: 3150Reputation: 3150Reputation: 3150Reputation: 3150Reputation: 3150Reputation: 3150Reputation: 3150Reputation: 3150Reputation: 3150Reputation: 3150
Many Linux programs will display an abbreviated help, abbreviated when compared to the man page, when you enter the program name followed by "--help." For example:

Code:
~$ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all                  do not ignore entries starting with .
  -A, --almost-all           do not list implied . and ..
      --author               with -l, print the author of each file
  -b, --escape               print C-style escapes for nongraphic characters
      --block-size=SIZE      scale sizes by SIZE before printing them; e.g.,
                               '--block-size=M' prints sizes in units of
                               1,048,576 bytes; see SIZE format 
(remainder of output omitted)
As an aside, I would suggest that learning native Linux commands is ultimately the best way to learn Linux. My experience has been that native Linux commands are more versatile and powerful than their Windows equivalents. Just my two cents.

Last edited by frankbell; 05-22-2016 at 08:34 PM.
 
1 members found this post helpful.
Old 05-22-2016, 08:44 PM   #11
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,298

Rep: Reputation: 222Reputation: 222Reputation: 222
Smile

Quote:
Originally Posted by monahanz View Post
From the above I'm clearly a newbie and a windows user.

My simple question is: what is the absolutely easiest way to have some kind of script so the "DIR: on the command line displays the current Linux directory as in windows. I'm currently using the Edison "Yocto" Linux version. As a windows user - - - not wishing to flame --- I find the Linux command line names totally scrambled letters. How for example does "df" get to be show the current directory? Has anybody out there written a type of script that makes it easy for Windows/DOS "die-hards" to use their favorite commands like dir, copy, erase, show, type….. in Linux.

John
Try this pdf file it's quite clear on its explanation.

http://www.digilife.be/quickreferenc...x%20Manual.pdf
https://www.sans.org/media/security-...utorial-v1.pdf

Last edited by JJJCR; 05-22-2016 at 09:03 PM. Reason: edit
 
1 members found this post helpful.
Old 05-22-2016, 11:00 PM   #12
monahanz
LQ Newbie
 
Registered: May 2016
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks everybody, all the above has been a big help. I'm adjusting to the new word have come from the dark side!

John
 
Old 05-23-2016, 12:09 AM   #13
monahanz
LQ Newbie
 
Registered: May 2016
Posts: 6

Original Poster
Rep: Reputation: Disabled
Smile

For other window users, I settled for:-
alias dir='ls -A -B -F -g -h'

Apparently in Linux you have to have a space before the '-' options!
 
Old 05-23-2016, 02:09 PM   #14
monahanz
LQ Newbie
 
Registered: May 2016
Posts: 6

Original Poster
Rep: Reputation: Disabled
Looks like I not out of the woods yet, Today I brought up the Edison/Linux board and found to my delight that my alias for dir=ls A B F g h worked fine (no matter where is was in the disk files tree).

Excited today I tried for some other DOS/CPM commands like:-
Alias copy=cp -I r
Alias stat=df H

They seemed to work fine. However what I cannot understand is when I reboot the system they are no longer recognized yet the original dir alias works. I tried doing the above two aliases in the top directory by using cd / still no luck.
Help please
John
 
Old 05-23-2016, 02:31 PM   #15
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 6,736

Rep: Reputation: 1918Reputation: 1918Reputation: 1918Reputation: 1918Reputation: 1918Reputation: 1918Reputation: 1918Reputation: 1918Reputation: 1918Reputation: 1918Reputation: 1918
It may be better to start getting used to using ls that way if you reinstall and forget to have your alias set up (for example) you'll still know what you're doing. I seem to recall that PowerShell will allow the use of ls on Windows (seem to recall using it in command prompt before that but not sure) so you can even take that habit back to modern Windows.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why I keep getting "Cannot run program "dir": error=13, Permissions denied" Maryam_Persian Other *NIX 2 05-20-2013 03:01 PM
exclude parameter of rsync- 'dir' vs "dir" vs dir rng Linux - General 5 06-13-2012 01:47 AM
What's the difference between "mv dir/* /tmp" and "find dir/* -print0 | xargs" ? thomas2004ch Linux - Software 8 04-19-2012 10:43 AM
How can I get the "current work dir" using C function? wuzhong Programming 5 09-16-2004 06:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration